str() of a tuple

Douglas Zongker dougz at
Wed Sep 4 17:24:54 EDT 2002

I'm sure this is a FAQ, but I haven't found a good explanation for one
of Python's most irritating behaviors:

   >>> a = -0.4
   >>> repr(a)
   >>> str(a)

So far, so good.
   >>> b = (a,)
   >>> repr(b)
   >>> str(b)                      # argggh.

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?

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


More information about the Python-list mailing list