[SciPy-user] Proposed change to Python's complex number formatting

Mark Dickinson dickinsm@gmail....
Mon Apr 27 16:30:56 CDT 2009


There's a proposal on python-dev[1] to change the way that the repr and str
functions behave for complex numbers in Python 3.1.  In brief, the suggestion
is that we should get:

>>> repr(4+2j)
'(4.0+2.0j)'

instead of

>>> repr(4+2j)
'(4+2j)'

That is, repr and str for complex numbers should behave more like
repr and str for floats:  both real and imaginary parts always include
*either* an exponent *or* a decimal point and at least one digit
following the point.

Raymond Hettinger pointed out that Numpy/Scipy users are amongst those
most likely to be affected, so I'm soliciting feedback from you all.  Any strong
feelings about this proposal, one way or the other?  Comments either
here, or (even better) on python-dev or Python's issue tracker[2] would be
very welcome.  The first beta of Python 3.1 is due this Saturday, so I'm
hoping to resolve this one way or the other by then.

Links: the thread is at:

[1] http://mail.python.org/pipermail/python-dev/2009-April/089030.html

and there's a corresponding issue in the Python bug tracker:

[2] http://bugs.python.org/issue5858

Mark Dickinson


More information about the SciPy-user mailing list