Show More
@@ -115,9 +115,15 b' def display(*objs, **kwargs):' | |||||
115 |
|
115 | |||
116 | for obj in objs: |
|
116 | for obj in objs: | |
117 |
|
117 | |||
118 |
# If _ipython_display_ is defined, use that to display this object. |
|
118 | # If _ipython_display_ is defined, use that to display this object. | |
119 | # it returns NotImplemented, use the _repr_ logic (default). |
|
119 | display_method = getattr(obj, '_ipython_display_', None) | |
120 | if not hasattr(obj, '_ipython_display_') or obj._ipython_display_(**kwargs) is NotImplemented: |
|
120 | if display_method is not None: | |
|
121 | try: | |||
|
122 | display_method(**kwargs) | |||
|
123 | except NotImplementedError: | |||
|
124 | pass | |||
|
125 | else: | |||
|
126 | continue | |||
121 |
|
|
127 | if raw: | |
122 |
|
|
128 | publish_display_data('display', obj, metadata) | |
123 |
|
|
129 | else: |
@@ -241,9 +241,14 b' class DisplayHook(Configurable):' | |||||
241 | """ |
|
241 | """ | |
242 | self.check_for_underscore() |
|
242 | self.check_for_underscore() | |
243 | if result is not None and not self.quiet(): |
|
243 | if result is not None and not self.quiet(): | |
244 |
# If _ipython_display_ is defined, use that to display this object. |
|
244 | # If _ipython_display_ is defined, use that to display this object. | |
245 | # it returns NotImplemented, use the _repr_ logic (default). |
|
245 | display_method = getattr(result, '_ipython_display_', None) | |
246 | if not hasattr(result, '_ipython_display_') or result._ipython_display_() is NotImplemented: |
|
246 | if display_method is not None: | |
|
247 | try: | |||
|
248 | return display_method() | |||
|
249 | except NotImplementedError: | |||
|
250 | pass | |||
|
251 | ||||
247 |
|
|
252 | self.start_displayhook() | |
248 |
|
|
253 | self.write_output_prompt() | |
249 |
|
|
254 | format_dict, md_dict = self.compute_format_data(result) |
General Comments 0
You need to be logged in to leave comments.
Login now