printing anomaly

Erik Max Francis max at alcyone.com
Mon Mar 21 02:03:48 CET 2005


Paul Rubin wrote:

> What's the deal with this?
> 
>     >>> print 3.2
>     3.2
>     >>> print [3.2]
>     [3.2000000000000002]
>     >>> 
> 
> Yes, I know that 3.2 isn't an exact binary fraction.  I'm wondering
> why it's converted differently depending on whether it's in a list.

repr vs. str.  The str of the sequence types prints the repr of their 
contents.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
   History is a set of lies agreed upon.
   -- Napoleon Bonaparte



More information about the Python-list mailing list