Re: cpython list __str__ method for floats

2007-09-12 Thread John Machin
On Sep 12, 10:59 pm, Duncan Booth <[EMAIL PROTECTED]> wrote:> [snip] > I believe the claim is that using the full 17 digits ensures the round- > tripping works even if you serialise and deserialise on different > systems, so perhaps we all pay a cost in our interactive sessions for > something wh

Re: cpython list __str__ method for floats

2007-09-12 Thread Duncan Booth
Bjoern Schliessmann <[EMAIL PROTECTED]> wrote: >> The idea that 13.3 is a 'rounded' value for the number, >> and that 13.301 is not a 'rounded' value of >> the number, is a common error of intuitive mathematics. > > I'm intrigued how /you/'d explain this, please do explain. I think

Re: cpython list __str__ method for floats

2007-09-12 Thread Bjoern Schliessmann
[david] wrote: > Leaving aside the question of why str should return repr, str doesn't "return" repr. str returns a "nice string representation" of an object. This "nice string representation" of a list is the opening square bracket, the repr of its contents seperated by comma, and the closing sq

Re: cpython list __str__ method for floats

2007-09-11 Thread [david]
Bjoern Schliessmann wrote: > [david] wrote: >> returns poorly formatted values: > > Please explain. > >> >>>str(13.3) >> '13.3' >> >>>str([13.3]) >> '[13.301]' > > This is quite a FAQ. > > str of a float returns the float, rounded to decimal precision. > > str of a list returns a

Re: cpython list __str__ method for floats

2007-09-11 Thread Bjoern Schliessmann
[david] wrote: > returns poorly formatted values: Please explain. > >>>str(13.3) > '13.3' > >>>str([13.3]) > '[13.301]' 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 content

Re: cpython list __str__ method for floats

2007-09-11 Thread TheFlyingDutchman
On Sep 11, 4:07 am, "[david]" <[EMAIL PROTECTED]> wrote: > returns poorly formatted values: > > >>>str(13.3) > '13.3' > >>>str([13.3]) > '[13.301]' > > [david] There is some difference in the way repr() and str() convert floats to strings: >>> a = 13.3 >>> print str(a) 13.3 >>> prin

cpython list __str__ method for floats

2007-09-11 Thread [david]
returns poorly formatted values: >>>str(13.3) '13.3' >>>str([13.3]) '[13.301]' [david] -- http://mail.python.org/mailman/listinfo/python-list