deriving from complex

Scott David Daniels scott.daniels at acm.org
Wed Mar 8 01:42:19 CET 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