Skip to content

Commit

Permalink
Merge pull request #12823 from dsblank/master
Browse files Browse the repository at this point in the history
Added clear kwarg to display()
  • Loading branch information
Carreau committed Apr 17, 2021
2 parents e08519b + 154c40b commit bb21d60
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion IPython/core/display_functions.py
Expand Up @@ -120,6 +120,9 @@ def display(*objs, include=None, exclude=None, metadata=None, transient=None, di
Set an id for the display.
This id can be used for updating this display area later via update_display.
If given as `True`, generate a new `display_id`
clear : bool, optional
Should the output area be cleared before displaying anything? If True,
this will wait for additional output before clearing. [default: False]
kwargs: additional keyword-args, optional
Additional keyword-arguments are passed through to the display publisher.
Expand Down Expand Up @@ -239,7 +242,8 @@ def display(*objs, include=None, exclude=None, metadata=None, transient=None, di
print(*objs)
return

raw = kwargs.pop('raw', False)
raw = kwargs.pop("raw", False)
clear = kwargs.pop("clear", False)
if transient is None:
transient = {}
if metadata is None:
Expand All @@ -263,6 +267,9 @@ def display(*objs, include=None, exclude=None, metadata=None, transient=None, di
if not raw:
format = InteractiveShell.instance().display_formatter.format

if clear:
clear_output(wait=True)

for obj in objs:
if raw:
publish_display_data(data=obj, metadata=metadata, **kwargs)
Expand Down

0 comments on commit bb21d60

Please sign in to comment.