floating point glitch
timr at probo.com
Tue Sep 28 08:21:12 CEST 2004
Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
>Michael Hoffman <m.h.3.9.1.without.dots.at.cam.ac.uk at example.com> writes:
>> Actually, print essentialy uses str() to get the string
>> representation. But repr(list) or str(list) still gets the repr() of
>> each item of the list rather than the str():
> >>> print .66
> >>> print [.66]
>Yucch! Also, str is not invertible:
Right! That's the point. str() is the perfect solution in those cases
where you want the language to lie to you. In many cases, that IS what you
want. repr() is the perfect solution when you need an invertible function.
And that's really the lesson that needs to be taught when this FAQ is A-ed.
- Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list