[SciPy-Dev] Custom __repr__?

Robert Kern robert.kern at gmail.com
Thu May 6 10:58:09 EDT 2021


On Thu, May 6, 2021 at 4:50 AM Pamphile Roy <roy.pamphile at gmail.com> wrote:

> Hi everyone,
>
> I was wondering if we would want to improve our *__repr__/__str__*
>  functions.
>
> This just came out with the Matplotlib release:
>
> https://matplotlib.org/stable/users/whats_new.html#ipython-representations-for-colormap-objects
>
>
> I can imagine something like this to display distributions for instance.
> There are many possible applications as you can imagine.
>
> FYI, this extra capabilities are available thanks to iPython reading extra
> *_repr_xxx* functions:
>
> https://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html#IPython.display.display
>
> Let me know what you think.
>

Because these would involve extra dependencies (either matplotlib or some
JavaScript), I would recommend starting with implementing these outside of
scipy. You can register formatters for objects without modifying the
objects themselves.

https://nbviewer.jupyter.org/github/ipython/ipython/blob/master/examples/IPython%20Kernel/Custom%20Display%20Logic.ipynb

-- 
Robert Kern
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scipy-dev/attachments/20210506/f35d582e/attachment.html>


More information about the SciPy-Dev mailing list