repr(complex) in Py3.1

Stefan Behnel stefan_ml at
Sat Oct 24 17:04:56 CEST 2009

Mark Dickinson, 24.10.2009 16:44:
> On Oct 24, 3:26 pm, Stefan Behnel wrote:
>> in Python 3.1.1, I get this:
>>   Python 3.1.1 (r311:74480, Oct 22 2009, 19:34:26)
>>   [GCC 4.3.2] on linux2
>>   Type "help", "copyright", "credits" or "license" for more information.
>>   >>> -(2j)
>>   (-0-2j)
>> The last line differs from what earlier Python versions printed here.
>> I know at least that the float repr() was modified in Py3.1, but is the
>> above behaviour intentional? It certainly breaks doctests, and I don't see
>> a good reason for that.
> Yes, it's intentional.  The problem with the 2.6 complex repr is that
> it doesn't accurately represent negative zeros, so that if you try
> to eval the result you don't end up with the same complex number

Ok, thanks. I guess we'll have to work around that in Cython's doctest
suite then.


More information about the Python-list mailing list