str() of a tuple

Erik Max Francis max at alcyone.com
Wed Sep 4 18:00:57 EDT 2002


Douglas Zongker wrote:

> Why, oh why does the str() of a container use the repr()s of the
> objects inside?  This seems to violate what the docs claim str() does
> -- "return a nicely printable representation of an object."  Would a
> sane implementation break something?

I presume this is an historical issue; perhaps if it were planned again
from scratch maybe it would have been done differently.  It certainly
does seem to cause a fair amount of confusion.

> Is there a convenient way to print out a tuple of floats so that the
> output is actually readable?

You can do it manually yourself:

	'(%s)' % ', '.join(map(str, T))

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ There is nothing so subject to the inconstancy of fortune as war.
\__/ Miguel de Cervantes
    Church / http://www.alcyone.com/pyos/church/
 A lambda calculus explorer in Python.



More information about the Python-list mailing list