[issue27363] Complex with negative zero imaginary part

Mark Dickinson report at bugs.python.org
Fri Jun 24 11:55:24 EDT 2016


Mark Dickinson added the comment:

> I suspect that literal_eval, on the other hand, should reproduce what the interpreter does

I think that's going to be awkward to achieve without making the behaviour of literal_eval significantly less obvious and more DWIMmy. And I'm not convinced that `literal_eval` should follow the behaviour of the complex constructor rather than the behaviour of plain `eval`.

Of course, the "right" fix here is to change the complex repr entirely so that it looks like the compound object that it is rather than an eval-able expression:

>>> repr(1+2j)
complex(1.0, 2.0)

That would break backwards compatibility, but given the number of times complaints come up on this tracker, I'm beginning to think it might be worth it.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27363>
_______________________________________


More information about the Python-bugs-list mailing list