'complex' function with string argument.

Chris Angelico rosuav at gmail.com
Tue Mar 18 08:11:45 CET 2014

On Tue, Mar 18, 2014 at 6:04 PM, Christian Gollwitzer <auriocus at gmx.de> wrote:
> As others have explained, the basic issue is the question how to parse an
> expression like
>         1+2i*3
> is it "complex(1+2i) times 3" or is it sum of 1 and product of complex 2i
> and 3?

The only way to have it be the former would be to mandate that all
complex literals have both parts, and you'd still lose clarity. You'd
probably want to have some other symbol rather than + in there, to
emphasize the connection:

1_--2j # Negative imaginary component

Otherwise, yeah, do what Python does and have imaginary literals only.


More information about the Python-list mailing list