@@ -120,6 +120,9 @@ def display(*objs, include=None, exclude=None, metadata=None, transient=None, di
120120 Set an id for the display.
121121 This id can be used for updating this display area later via update_display.
122122 If given as `True`, generate a new `display_id`
123+ clear : bool, optional
124+ Should the output area be cleared before displaying anything? If True,
125+ this will wait for additional output before clearing. [default: False]
123126 kwargs: additional keyword-args, optional
124127 Additional keyword-arguments are passed through to the display publisher.
125128
@@ -239,7 +242,8 @@ def display(*objs, include=None, exclude=None, metadata=None, transient=None, di
239242 print (* objs )
240243 return
241244
242- raw = kwargs .pop ('raw' , False )
245+ raw = kwargs .pop ("raw" , False )
246+ clear = kwargs .pop ("clear" , False )
243247 if transient is None :
244248 transient = {}
245249 if metadata is None :
@@ -263,6 +267,9 @@ def display(*objs, include=None, exclude=None, metadata=None, transient=None, di
263267 if not raw :
264268 format = InteractiveShell .instance ().display_formatter .format
265269
270+ if clear :
271+ clear_output (wait = True )
272+
266273 for obj in objs :
267274 if raw :
268275 publish_display_data (data = obj , metadata = metadata , ** kwargs )
0 commit comments