why no arg, abs methods for comlex type?
Dan Bishop
danb_83 at yahoo.com
Fri Aug 5 11:48:59 EDT 2005
Terry Reedy wrote:
> "Daniel Schüle" <uval at rz.uni-karlsruhe.de> wrote in message
> news:dcvqc2$8oi$1 at news2.rz.uni-karlsruhe.de...
...
> > unfortunately there is no arg method to get the angle
> > of the complex number
>
> I agree that this is a deficiency. I would think .angle() should be a
> no-param method like .conjugate(), though its internal implementation would
> need access to the appropriate cmath functions.
You need math, not cmath.
def arg(z):
"""The Argument of z, in radians."""
z += 0j # make it work on real inputs
return math.atan2(z.imag, z.real)
More information about the Python-list
mailing list