Re: PyObject __repr__, __str__ and toString
Samuele Pedroni <[email protected]>
| Newsgroups | gmane.comp.lang.jython.devel |
|---|---|
| Message-ID | <CAGwLUHbRXcqPdeEvm5VBRAcnhGW=Bq6kp97=BX=0EQwCvU0Kmw@mail.gmail.com> |
On Wed, Dec 12, 2018 at 10:35 AM Jeff Allen <[email protected]> wrote: > We're discussing this in a couple of places already, but I wanted to ask > here in case there are old hands subscribed who can shed any light. > > http://bugs.jython.org/issue2719 > > https://github.com/jythontools/jython/pull/126 > > PyObject.java contains some comments I've never understood and have had > difficulty following > ( > https://hg.python.org/jython/file/tip/src/org/python/core/PyObject.java#l218). > > It seems advice only relevant to those who extend PyObject, which is > mostly us. And we certainly don't follow it in PyObjectDerived which > contains the mechanism by which Python authors override __str__ and > where toString delegates to __repr__. > > for what is worth that comment seems to be from before new-style classes support, when indeed extending PyObject was easy/natural and was done also outside of the Jython code base itself often, and the code was following Java patterns more than the slightly quirky patterns needed to implement new-style semantics, so telling people implement toString and the runtime will do the rest made sense. _______________________________________________ Jython-dev mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/jython-dev