[Python-Dev] return type of __complex__

Greg Ewing greg.ewing at canterbury.ac.nz
Sat Oct 20 01:35:13 CEST 2012


Antonio Cuni wrote:
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> TypeError: __complex__ should return a complex object
> 
> i.e., the complex constructor does not check that __complex__ returns an
> actual complex, while the cmath functions do.

Looks to me like cmath is being excessively finicky
here. Why shouldn't a float be usable in *any* context
expecting a complex?

-- 
Greg


More information about the Python-Dev mailing list