Show More
@@ -115,17 +115,23 b' def display(*objs, **kwargs):' | |||
|
115 | 115 | |
|
116 | 116 | for obj in objs: |
|
117 | 117 | |
|
118 |
# If _ipython_display_ is defined, use that to display this object. |
|
|
119 | # it returns NotImplemented, use the _repr_ logic (default). | |
|
120 | if not hasattr(obj, '_ipython_display_') or obj._ipython_display_(**kwargs) is NotImplemented: | |
|
121 |
|
|
|
122 | publish_display_data('display', obj, metadata) | |
|
123 | else: | |
|
124 | format_dict, md_dict = format(obj, include=include, exclude=exclude) | |
|
125 |
|
|
|
126 | # kwarg-specified metadata gets precedence | |
|
127 | _merge(md_dict, metadata) | |
|
128 |
|
|
|
118 | # If _ipython_display_ is defined, use that to display this object. | |
|
119 | display_method = getattr(obj, '_ipython_display_', None) | |
|
120 | if display_method is not None: | |
|
121 | try: | |
|
122 | display_method(**kwargs) | |
|
123 | except NotImplementedError: | |
|
124 | pass | |
|
125 | else: | |
|
126 | continue | |
|
127 | if raw: | |
|
128 | publish_display_data('display', obj, metadata) | |
|
129 | else: | |
|
130 | format_dict, md_dict = format(obj, include=include, exclude=exclude) | |
|
131 | if metadata: | |
|
132 | # kwarg-specified metadata gets precedence | |
|
133 | _merge(md_dict, metadata) | |
|
134 | publish_display_data('display', format_dict, md_dict) | |
|
129 | 135 | |
|
130 | 136 | |
|
131 | 137 | def display_pretty(*objs, **kwargs): |
@@ -241,16 +241,21 b' class DisplayHook(Configurable):' | |||
|
241 | 241 | """ |
|
242 | 242 | self.check_for_underscore() |
|
243 | 243 | if result is not None and not self.quiet(): |
|
244 |
# If _ipython_display_ is defined, use that to display this object. |
|
|
245 | # it returns NotImplemented, use the _repr_ logic (default). | |
|
246 | if not hasattr(result, '_ipython_display_') or result._ipython_display_() is NotImplemented: | |
|
247 |
|
|
|
248 | self.write_output_prompt() | |
|
249 | format_dict, md_dict = self.compute_format_data(result) | |
|
250 | self.write_format_data(format_dict, md_dict) | |
|
251 | self.update_user_ns(result) | |
|
252 |
|
|
|
253 | self.finish_displayhook() | |
|
244 | # If _ipython_display_ is defined, use that to display this object. | |
|
245 | display_method = getattr(result, '_ipython_display_', None) | |
|
246 | if display_method is not None: | |
|
247 | try: | |
|
248 | return display_method() | |
|
249 | except NotImplementedError: | |
|
250 | pass | |
|
251 | ||
|
252 | self.start_displayhook() | |
|
253 | self.write_output_prompt() | |
|
254 | format_dict, md_dict = self.compute_format_data(result) | |
|
255 | self.write_format_data(format_dict, md_dict) | |
|
256 | self.update_user_ns(result) | |
|
257 | self.log_output(format_dict) | |
|
258 | self.finish_displayhook() | |
|
254 | 259 | |
|
255 | 260 | def flush(self): |
|
256 | 261 | if not self.do_full_cache: |
General Comments 0
You need to be logged in to leave comments.
Login now