repr(complex) in Py3.1

Stefan Behnel stefan_ml at behnel.de
Sat Oct 24 16:26:53 CEST 2009


Hi,

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
  2j
  >>> -2j
  -2j
  >>> -0-2j
  -2j
  >>> (-0-2j)
  -2j
  >>> -(2j)
  (-0-2j)

The last line differs from what earlier Python versions printed here:

  Python 2.6.2 (r262:71600, Oct 22 2009, 20:58:58)
  [GCC 4.3.2] on linux2
  Type "help", "copyright", "credits" or "license" for more information.
  >>> 2j
  2j
  >>> -2j
  -2j
  >>> -0-2j
  -2j
  >>> (-0-2j)
  -2j
  >>> -(2j)
  -2j

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.

Stefan



More information about the Python-list mailing list