-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Define __repr__
, not __str__
for transforms.
#11173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
str falls back on repr (but not the other way round), so `def __repr__(self): return str(self)` was causing a recursion error. Defining `__repr__` directly side-steps the issue.
Not sure, it's actually good to have that verbose reprs. On the other hand, someone had decided to have them by pulling in the str. So it's probably ok and at least not a change to the previous behavior.. |
OK, my quick study of this was that https://stackoverflow.com/questions/1436703/difference-between-str-and-repr OTOH, I think I agree w/ @timhoffm that it seems strange to have such a verbose |
My personal two bits on this: I like the verbosity when doing |
Print will use the str form. I’m totally for the str form as the verbose version we have. |
Ah, ok, so in which case would the |
90% sure thats the |
Maybe we should just remove the When is is used?
as can seen in the following example which has the
If that's not an option, at least, we should still rework |
One thing that might be useful is that when you type |
Supplying both I think best would be to provide both, or to use |
OK, I think we agreed on the call that
But this was just @efiring , @story645, and myself, so happy to dicsuss further, as that is hardly a quorum. reference: https://docs.python.org/3/reference/datamodel.html#object.__repr__ |
Closing: alternative #11189 is merged. |
str falls back on repr (but not the other way round), so
def __repr__(self): return str(self)
was causing a recursion error.Defining
__repr__
directly side-steps the issue.(https://docs.python.org/3/reference/datamodel.html#object.__str__, e.g.
)
Supersedes #11171; closes #11163.
PR Summary
PR Checklist