Re: [Tutor] list output -- float output

2008-11-14 Thread spir
Thank you for the advice. Actually, what annoys me is that list textual output, either with print or str(), calls repr() for each item of the list, instead of str(). That's why I had these strange things with floats, as illustrated in my first post on the topic: class Seq(list): ''' se

Re: [Tutor] list output -- float output

2008-11-14 Thread Lie Ryan
On Fri, 14 Nov 2008 15:21:17 +0100, spir wrote: > Well, actually not really I guess. I asked for rounded floats, not > full-precision ones. > Now, after more reflexion on the topic, I understand that even rounded > floats need to keep full precision internally, because of the 'modular' > difference

Re: [Tutor] list output -- float output

2008-11-14 Thread spir
A.T.Hofkamp a écrit : > spir wrote: >> # By the way, I do not understand at all the behaviour of repr on >> rounded floats: >> x = round(1.1,1) >> print x, repr(x), "%s" %x >> 1.1 1.1001 1.1 > > This is a FAQ question: > > http://www.python.org/doc/faq/general/#why-are-floating-point-

Re: [Tutor] list output -- float output

2008-11-14 Thread spir
[addendum] Well, actually, the previous Seq didn't solve all problems. Obvious case of nested lists. Below a modified version. denis class Seq(list): ''' specialized sequence type with improved str Override list's behaviour that str(list) calls repr instead of str on it

Re: [Tutor] list output -- float output

2008-11-14 Thread A.T.Hofkamp
spir wrote: # By the way, I do not understand at all the behaviour of repr on rounded floats: x = round(1.1,1) print x, repr(x), "%s" %x 1.1 1.1001 1.1 This is a FAQ question: http://www.python.org/doc/faq/general/#why-are-floating-point-calculations-so-inaccurate Sincerely, Albe

[Tutor] list output -- float output

2008-11-14 Thread spir
Below an illustration of what troubles me a bit. denis class Seq(list): ''' specialized sequence type with improved str Override list's behaviour that list.__str__ calls __repr__ instead of __str__ on items. ??? ''' def __str__(self):