'complex' function with string argument.

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


Ian Kelly <ian.g.kelly at gmail.com>:

> On Wed, Mar 19, 2014 at 4:09 AM, Marko Rauhamaa <marko at pacujo.net> wrote:
>> 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.
>
> When is it ever useful though? [...] It would be better to raise an
> exception in either of the cases above, in my opinion.

I don't think it matters one way or another.

Medieval mathematicians had to address an analogous issue when they had
to decide if

   x + 0

was meaningful. After all, adding nothing doesn't make any sense and
should raise a ValueError exception...


Marko



More information about the Python-list mailing list