repr(complex) in Py3.1

"Martin v. Löwis" martin at v.loewis.de
Sat Oct 24 10:46:15 EDT 2009


> 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.

I don't know whether it was intentional, but it looks right to me.
2j is the complex number +0.0+2.0j (right?). Then, -(2j) is the negated
value of this, i.e. -0.0-2.0j (*). It seems that the complex type made
no distinction between +0.0 and -0.0 in the past, but it should (just as
the float type does).

Regards,
Martin

(*) this is different from -2j, where the sign applies to the imaginary
part only.



More information about the Python-list mailing list