print attitude

Erik Max Francis max at
Mon Jul 7 23:29:16 CEST 2003

Donn Cave wrote:

> Speaking of floats, I believe lists containing floats are the main
> case where people really resist seeing the sense in this - but it's
> easier to call that a wart in float's repr, since they're as bugged
> wherever they see it and in my opinion rightly so.

Personally, I think the internal difference between str and repr hits
right upon a proper difference:  str is for a "reasonable"
human-readable representation, and repr is for as faithful and
informative a representation as possible.  These both have their uses
and I approve of the distinction.

The confusion, in my opinion, comes from the fortuity of when str vs.
repr is used, which is easy to understand once you've been exposed to it
but is very confusing at first.  Even for someone who's familiar with
the inaccuracy of floating point, you can very easily see how someone
would be confused and worried about the following code fragment:

>>> x = 1.4
>>> print x
>>> print [x]

   Erik Max Francis && max at &&
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ We're here to preserve democracy, not to practice it.
\__/  Capt. Frank Rasmey

More information about the Python-list mailing list