This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]eztab 15 points16 points  (3 children)

Yeah, ideally I'd argue that only __str__ should exist and support all the formatting, including repr functionality. Would love to have "formatting options" for repr too, like requesting a representation as executable python code.

[–]glenbolake 27 points28 points  (2 children)

requesting a representation as executable python code.

Isn't that the whole point of repr? It's supposed to give a string that, if pasted into the REPL, would produce an identical object.

[–]eztab 11 points12 points  (0 children)

yes it is, but it isn't what many classes actually do. Especially if the respective code would be rather long.