Complex evaluation bug
Christophe
chris.cavalaria at free.fr
Fri May 19 04:29:25 EDT 2006
Fredrik Lundh a écrit :
> Christophe wrote:
>
>>> So, putting them together, you could expect
>>> eval(repr(a))
>>> to reproduce a, and in fact it does so.
>>
>>
>> Says who ?
>>
>> Python 2.4.2 (#67, Sep 28 2005, 12:41:11) [MSC v.1310 32 bit (Intel)]
>> on win32
>> Type "help", "copyright", "credits" or "license" for more information.
>> >>> repr(1+3j)
>> '(1+3j)'
>> >>> complex(repr(1+3j))
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in ?
>> ValueError: complex() arg is a malformed string
>> >>>
>
>
> in what language is "eval" spelled "complex" ?
>
> </F>
>
Oups, I was too fast to read what was written. I though you only changed
one of the terms ( str -> repr ).
You'll note that repr and str produce the exact same result for complex.
And also, I'm not sure using eval anywhere is a good idea so it probably
doesn't help for what the OP wants to do.
More information about the Python-list
mailing list