print attitude

Donn Cave donn at u.washington.edu
Tue Jul 8 00:03:22 CEST 2003


In article <3F09E62C.D1A8D53A at alcyone.com>,
 Erik Max Francis <max at alcyone.com> wrote:

> 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
> 1.4
> >>> print [x]
> [1.3999999999999999]

Maybe it isn't time to wade back into this, only to repeat
ad nauseum the same old discussion.  My point is that there
is a way to look at str vs. repr that 1) doesn't use utterly
ambiguous phrases like "reasonable" or "human-readable", and
2) makes it more or less self-evident that list will repr its
contents.  For more, see 61-message thread 
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&threadm=uw1i4nqpl33h.1
l3wpteil4jb0.dlg%4040tude.net&rnum=1&prev=/groups%3Fhl%3Den%26lr%3D%26ie%
3DUTF-8%26selm%3Duw1i4nqpl33h.1l3wpteil4jb0.dlg%254040tude.net

   Donn Cave, donn at u.washington.edu




More information about the Python-list mailing list