Jeffrey Yasskin wrote: > This interpretation implies that complex should provide __float__() to > return the non-imaginary portion of a complex number. Is that what you > intend?
No, please don't. If somebody wants to implement __float__ for complex numbers please define it as hypot(complex) / sqrt(c.real**2 + c.img**2). In my opinion float(complex) does do the most sensible thing. It fails and points the user to abs(). >>> float(complex(1,1)) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can't convert complex to float; use abs(z) >>> abs(complex(1,1)) 1.4142135623730951 _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com