Representation of floats (-> Mark Dickinson?)

jmfauth wxjmfauth at gmail.com
Wed Sep 7 10:21:20 CEST 2011


On 7 sep, 08:56, Mark Dickinson <mdickin... at enthought.com> wrote:
> On Sep 7, 4:58 am, casevh <cas... at gmail.com> wrote:
>
> > IIRC, Python
> > 3.2 changed (for floats) __str__ to call __repr__.
>
> Yes, exactly:  str and repr of a float are identical in Python 3.2 +
>
> I'm also puzzled by the
>
> 2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]
> [...]>>> 1.1 * 1.1
>
> 1.21
>
> in jmf's message.  Cut-and-paste typo?
>
> --
> Mark


No. But, it's *my* mistake. I'm using a modified sys.displayhook which
uses a print statement (mainly for language reason). If forgot to
reset to the initial/default state for these tests when working
with too many opened interactive interpreters.
Sorry for the noise.


>>> sys.version
'2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]'
>>>
>>> 1.1 * 1.1
1.21
>>> 'éléphant'
éléphant
>>>
>>> sys.displayhook = sys.__displayhook__
>>> 1.1 * 1.1
1.2100000000000002
>>> 'éléphant'
'\xe9l\xe9phant'
>>> sys.version
'2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit (Intel)]'
>>>

jmf



More information about the Python-list mailing list