cpython list __str__ method for floats
Bjoern Schliessmann
usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Tue Sep 11 07:52:46 EDT 2007
[david] wrote:
> returns poorly formatted values:
Please explain.
> >>>str(13.3)
> '13.3'
> >>>str([13.3])
> '[13.300000000000001]'
This is quite a FAQ.
str of a float returns the float, rounded to decimal precision.
str of a list returns a square brackets enclosed enumeration of the
contents (using repr on them). repr of a float returns the float in
full precision.
Regards,
Björn
--
BOFH excuse #442:
Trojan horse ran out of hay
More information about the Python-list
mailing list