--- title: Title keywords: fastai sidebar: home_sidebar nb_path: "venv/Lib/site-packages/nbconvert/preprocessors/tests/files/Clear Output.ipynb" ---
{% raw %}
{% endraw %} {% raw %}
from __future__ import print_function
from IPython.display import clear_output
{% endraw %} {% raw %}
for i in range(10):
    clear_output()
    print(i)
9
{% endraw %} {% raw %}
print("Hello world")
clear_output()
{% endraw %} {% raw %}
print("Hello world", end='')
clear_output(wait=True)  # no output after this
Hello world
{% endraw %} {% raw %}
print("Hello", end='')
clear_output(wait=True)  # here we have new output after wait=True
print("world", end='')
world
{% endraw %} {% raw %}
handle0 = display("Hello world", display_id="id0")
'Hello world'
{% endraw %} {% raw %}
handle1 = display("Hello", display_id="id1")
'world'
{% endraw %} {% raw %}
handle1.update('world')
{% endraw %} {% raw %}
handle2 = display("Hello world", display_id="id2")
clear_output()  # clears all output, also with display_ids
{% endraw %} {% raw %}
handle3 = display("Hello world", display_id="id3")
clear_output(wait=True)
'Hello world'
{% endraw %} {% raw %}
handle4 = display("Hello", display_id="id4")
clear_output(wait=True)
print('world', end='')
world
{% endraw %} {% raw %}
handle4.update('Hello world')  # it is cleared, so it should not show up in the above cell
{% endraw %}