diff --git a/IPython/core/display_functions.py b/IPython/core/display_functions.py index 5b49faa..9f566b4 100644 --- a/IPython/core/display_functions.py +++ b/IPython/core/display_functions.py @@ -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. @@ -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: @@ -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)