round function problem
gnb at itga.com.au
Tue Sep 6 10:02:48 CEST 2005
> Is it a bug or a control behavour ? I don't understand ?!?!?!?!...
It's a case of applying different float-to-text rounding in different
situations, on a variable that (even after round()) is not representable
in binary floatingpoint.
"print var" does one sort of string conversion (using str()), "print
[var]" does another type (using repr() on the list element). The
underlying value is the same, it's just printed differently.
>>>> var = round(0.5**0.5, 2)
>>>> print var
>>>> print [var]
>>>> print str(var)
>>>> print repr(var)
More information about the Python-list