##// END OF EJS Templates
add a little detail to custom repr method docs...
Min RK -
Show More
@@ -26,11 +26,13 b' Rich display'
26
26
27 Custom methods
27 Custom methods
28 ----------------------
28 ----------------------
29
29 IPython can display richer representations of objects.
30 IPython can display richer representations of objects.
30 To do this, you can define ``_ipython_display_()``, or any of a number of
31 To do this, you can define ``_ipython_display_()``, or any of a number of
31 ``_repr_*_()`` methods.
32 ``_repr_*_()`` methods.
32 Note that these are surrounded by single, not double underscores.
33 Note that these are surrounded by single, not double underscores.
33
34
35
34 .. list-table:: Supported ``_repr_*_`` methods
36 .. list-table:: Supported ``_repr_*_`` methods
35 :widths: 20 15 15 15
37 :widths: 20 15 15 15
36 :header-rows: 1
38 :header-rows: 1
@@ -76,7 +78,17 b' Note that these are surrounded by single, not double underscores.'
76 - ?
78 - ?
77 - ?
79 - ?
78
80
79 If the methods don't exist, or return ``None``, the standard ``repr()`` is used.
81 If the methods don't exist, the standard ``repr()`` is used.
82 If a method exists and returns ``None``, it is treated the same as if it does not exist.
83 In general, *all* available formatters will be called when an object is displayed,
84 and it is up to the UI to select which to display.
85 A given formatter should not generally change its output based on what other formats are available -
86 that should be handled at a different level, such as the :class:`~.DisplayFormatter`, or configuration.
87
88 ``_repr_*_`` methods should *return* data of the expected format and have no side effects.
89 For example, ``_repr_html_`` should return HTML as a `str` and ``_repr_png_`` should return PNG data as `bytes`.
90
91 If you wish to take control of display via your own side effects, use ``_ipython_display_()``.
80
92
81 For example::
93 For example::
82
94
General Comments 0
You need to be logged in to leave comments. Login now