Rounding curiosity

Delaney, Timothy C (Timothy) tdelaney at avaya.com
Wed Nov 17 18:14:13 EST 2004


Donn Cave wrote:

> Actually it will anyway - once you use "print", you
> get a str() automatically, and that rounds off in a
> way that happens to give you the same result in this
> case - so the formatting above is superfluous unless
> the occasional trailing zero is important.  If repr()
> did the same, we'd hear a lot less of this.

`repr` used to do the same - it was changed precisely *because* it was
lying.

`str` is meant to give a human-readable representation. `repr` is meant
to give an *accurate* representation (where possible).

Tim Delaney



More information about the Python-list mailing list