"Nick Maclaren" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > > x = (1.234567890125, 1.2345678901255) > print x > print x[0], x[1] > >>>> (1.2345678901249999, 1.2345678901254999) >>>> 1.23456789012 1.23456789013 > > Is there a rational reason, or is that simply an artifact of the way > that the code has evolved? It is clearly not a bug :-)
print x[0] gives the same result as printing str(x[0]), the value of x formatted as a string (rounded to a sensible number of places). x[0] at the command prompt gives the same result as printing repr(x), the representation of the text value as a string. When you do print on a tuple it doesn't recursively call str(), so you get the repr representations. You can get similar results with anything where the str() and repr() values are different. e.g. x = ( u'a', u'b') -- http://mail.python.org/mailman/listinfo/python-list