why no arg, abs methods for comlex type?

Robert Kern rkern at ucsd.edu
Sat Aug 6 03:04:49 EDT 2005


Daniel Schüle wrote:
> [...]
> 
>  > Derive your own subclass of complex and define those methods.
> 
> I think something as basic as an angle/arg of complex number
> definetly belongs to the interface, and it would not even require a
> great effort to put it there

<shrug> Okay. Write a patch. Personally, I would prefer that it be a 
function in cmath rather than a method because then it could be made to 
work on integers and regular floats, too.

> most complex formulas out there use Euler representation
> it's a waste of code lines (and programmers time)
> to write 3 liner functions for the transformion between
> a+bj <-> (r,angle)

It's a very, very tiny outlay of effort on the programmer's part that 
only has to happen once in their career.

> Python makes things covenient
> so we have complex numbers in the core language
> the calculations where perfectly possible without them
> using (re, im) tupels and many many sin/cos in the code
> but imagine how ugly it would be ..

I don't have to imagine. It's not all that ugly.

> I would like see Python as a competitor to Matlab etc

I think it is already.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
  Are the graves of dreams allowed to die."
   -- Richard Harter




More information about the Python-list mailing list