?
=?ISO-8859-1?Q?Sch=FCle_Daniel?=
Hello
I am trying to customize the handling of complex numbers
what I am missing is a builtin possibility to create
complex numbers in polar coordinates
so first I wrote a standalone function
.... re, im = r*cos(arg), r*sin(arg)
.... return re + im*1j
then I tried to extend this to a class
.... def __init__(self,x,y,polar=False):
.... if not polar:
.... self.re, self.im = x,y
.... else:
.... self.re, self.im = x*cos(y), x*sin(y)
....Traceback (most recent call last):
and got stuck with this error
it seems that last argument is rejected
because complex wants to have 2 arguments
but this works well ..
.... def __init__(self,a):
.... self.a = a
........ def __init__(self,a,b):
.... self.a = a
.... self.b = b
....
what's causing the above exception?
one more question
.... def __init__(self,x,y):
.... self.real = x
.... self.imag = y
....Traceback (most recent call last):
File "<stdin>", line 1, in ?
how can I work around this problem?
Regards, Daniel
I am trying to customize the handling of complex numbers
what I am missing is a builtin possibility to create
complex numbers in polar coordinates
so first I wrote a standalone function
.... re, im = r*cos(arg), r*sin(arg)
.... return re + im*1j
then I tried to extend this to a class
.... def __init__(self,x,y,polar=False):
.... if not polar:
.... self.re, self.im = x,y
.... else:
.... self.re, self.im = x*cos(y), x*sin(y)
....Traceback (most recent call last):
and got stuck with this error
it seems that last argument is rejected
because complex wants to have 2 arguments
but this works well ..
.... def __init__(self,a):
.... self.a = a
........ def __init__(self,a,b):
.... self.a = a
.... self.b = b
....
what's causing the above exception?
one more question
.... def __init__(self,x,y):
.... self.real = x
.... self.imag = y
....Traceback (most recent call last):
File "<stdin>", line 1, in ?
how can I work around this problem?
Regards, Daniel