[SciPy-Dev] Custom __repr__?
Pamphile Roy
roy.pamphile at gmail.com
Thu May 6 11:10:11 EDT 2021
Thanks for your inputs Robert.
> 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.
We already have a soft dependency on matplotlib in spatial for instance with a few helper functions (https://scipy.github.io/devdocs/reference/spatial.html#plotting-helpers <https://scipy.github.io/devdocs/reference/spatial.html#plotting-helpers>).
It would be the same here, something completely optional. Plus here the functions are private and don’t conflict with Python’s internals.
> https://nbviewer.jupyter.org/github/ipython/ipython/blob/master/examples/IPython%20Kernel/Custom%20Display%20Logic.ipynb <https://nbviewer.jupyter.org/github/ipython/ipython/blob/master/examples/IPython%20Kernel/Custom%20Display%20Logic.ipynb>
Nice examples, this is exactly this I had in mind.
Well, this registration outside is quite complicated IMO… Personally, I think I would even prefer to mock the underlying object and add the _repr_xxx I want…
Cheers,
Pamphile
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.python.org/pipermail/scipy-dev/attachments/20210506/05d7ef12/attachment.html>
More information about the SciPy-Dev
mailing list