str vs repr Re: Rounding Bug in Python 2.0! - ugh

Alex Martelli aleaxit at yahoo.com
Wed Nov 1 13:27:07 CET 2000


"Gordon Williams" <g_will at cyberus.ca> wrote in message
news:8tncdk$frm$1 at news2.ottawa.cyberus.ca...
    [snip]
> >>> x=3.123456
> >>> round(x,3)
> 3.1230000000000002
>
> Someone is going to start talking about machine round off errors, but this
> is a BIG UGH!!
> It is not what is intuitively expected.  Can we go back to the good old
days
> when 1.5.2 lied to us and gave us the answer that we expect and need!!

It might be nice to have a commandline switch, or settable
sys.something, etc, to tell the interactive toplevel to switch
between using str or repr to present results of expressions.

Given the number of posts about this, including ones from
experienced people, this might perhaps help.  How does
one open a PEP about it...?

Of course, floating-point will just about never give you "what
is intuitively expected" -- unless you happen to have enough
relevant experience that you've come to 'intuitively expect'
what floating-point happens to give you:-).  But fixes for THAT
issue (rationals, a decimal-arithmetic package, etc) are not
as snap-fingers-easy as the str-vs-repr switch...:-)


Alex






More information about the Python-list mailing list