deriving from complex

Scott David Daniels scott.daniels at acm.org
Tue Mar 7 19:42:19 EST 2006


Schüle Daniel wrote:
...
> btw I like how Ruby handles the creation of complex numbers
> 
> c = Complex(1,1)
> p = Complex.polar(1,45.0/360*2*PI)

class Complex(complex):
     @classmethod
     def polar(class_, radius, angle):
         return class_(radius * cos(angle), radius * sin(angle))

--Scott David Daniels
scott.daniels at acm.org



More information about the Python-list mailing list