Why not FP for Money?
aleaxit at yahoo.com
Fri Sep 24 13:14:00 CEST 2004
Paul Rubin <http://phr.cx@NOSPAM.invalid> wrote:
> aleaxit at yahoo.com (Alex Martelli) writes:
> > yep, str(35.72) == '35.72'.
> >>> 35.72
> I wonder why str(35.72) is different from repr(35.72).
Because they serve different purposes. As the Tutorial (appendix B)
puts it, "you'll see the result you expect in the end if you simply
round the display of your final results to the number of decimal digits
you expect. str() usually suffices". repr is such [when feasible] that
x==eval(repr(x)), str on the other hand is expected to present a nice
display for humans, fudging things a bit for the purpose.
More information about the Python-list