why no arg, abs methods for comlex type?

Daniel Schüle uval at rz.uni-karlsruhe.de
Fri Aug 5 09:42:41 EDT 2005


Hello all,

I often have to deal with complex numbers
using python iteractive as calculator

I wonder why there are no methods like arg, abs

well one can use
c = 1+1j
abs(c)

In my opinion it would also be nice to have the
possibility to write it as
c.abs()
it looks more OO

unfortunately there is no arg method to get the angle
of the complex number
of course it easy to write one on your own
(that's what I have done for myself)
but differnt people will create and reinvite the wheel
over and over again
while reading alien code one will have to spend 2 seconds
remembering the function names etc

consider
c = 1+1j
c.arg(angle_mode = cmath.GRAD) -> 45.0
or
c.arg(angle_mode = cmath.RAD) -> 0.7853..

I would also like to see some more functions to make
calculations with complex number more convenient
e.g.
c = 27
c.pow(numerator = 1, denominator = 3,
       mode = cmath.EULER, angle_mode = cmath.GRAD)
-> ((3,0), (3,120), (3,240))

what do you think about it?
maybe there exists some proposals aiming this goal?

-- 
Daniel



More information about the Python-list mailing list