{ "worksheets": [ { "cells": [ { "source": "A demonstration of the ability to clear the output of a cell during execution.", "cell_type": "markdown" }, { "cell_type": "code", "language": "python", "outputs": [], "collapsed": true, "prompt_number": 8, "input": "from IPython.core.display import clear_output, display" }, { "cell_type": "code", "language": "python", "outputs": [], "collapsed": false, "prompt_number": 4, "input": "import time" }, { "source": "First we show how this works with ``display``:", "cell_type": "markdown" }, { "cell_type": "code", "language": "python", "outputs": [], "collapsed": false, "prompt_number": 17, "input": "for i in range(10):\n display(\"Time step: %i\" % i)\n time.sleep(0.5)\n clear_output()" }, { "source": "Next, we show that ``clear_output`` can also be used to create a primitive form of animation using\nmatplotlib:", "cell_type": "markdown" }, { "cell_type": "code", "language": "python", "outputs": [], "collapsed": false, "prompt_number": 20, "input": "for i in range(10):\n figure()\n plot(rand(100))\n show()\n time.sleep(0.1)\n clear_output()" } ] } ], "metadata": { "name": "clear_output" }, "nbformat": 2 }