__str__ vs __repr__

John Roth newsgroups at jhrothjr.com
Thu Jun 16 08:22:00 EDT 2005


"Donn Cave" <donn at drizzle.com> wrote in message 
news:1118898421.887013 at yasure...
> Quoth "John Roth" <newsgroups at jhrothjr.com>:
> ...
> | str() should be something that's meaningful to a human being when
> | it's printed or otherwise rendered.
>
> I can't believe how many people cite this explanation - meaningful,
> friendly, pretty to a human being.  What on earth does this mean,
> that couldn't be said more unambiguously?
>
> According to my impression of common applications for Python programs,
> rarely would anyone be looking at the output for esthetic gratification.
> I mean, imagine your users casting an appraising eye over the contours
> of a phrase emitted by the program, and praising the rhythmic effect of
> the punctuation it chose to use, or negative space created by tabs.  heh.
>
> Whether for human eyes or any destination, properly formed output will
> carry the information that is required for the application, in a complete
> and unambiguous way and in the format that is most readily processed,
> and it will omit extraneous information.  Are we saying anything other
> than this?

I thought that's what I said. I fail to see how you derive any other
meaning from it. Possibly less verbiage and a concerete example
of how "meaningful" equates to "esthetics that obfustificate understanding"
and does not equate to "immediately useable, without having to wade
through a lot of irrelvant mental transformations" would help my 
understanding.

John Roth
>
> Donn Cave, donn at drizzle.com 




More information about the Python-list mailing list