'complex' function with string argument.

Marko Rauhamaa marko at pacujo.net
Wed Mar 19 06:09:06 EDT 2014


wxjmfauth at gmail.com:

> Le mercredi 19 mars 2014 09:51:20 UTC+1, Marko Rauhamaa a écrit :
>> wxjmfauth at gmail.com:
>> >>>> complex(2, 1+1j)
>> > (1+1j)
>> 
>> I find it neat, actually.
>
>>>> # tricky: yes, neat: no
>>>> complex(1+1j, 2)
> (1+3j)

So complex(a, b) is documented to produce a+bj when a and b are integers
or floats. What's more natural than saying it produces a+bj when a and b
are complex numbers? It's a straightforward generalization that in no
way violates the more limited documentation.


Marko



More information about the Python-list mailing list