deriving from complex

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


Scott David Daniels wrote:
> Schüle Daniel wrote:
>> ... 
And, of course, I reply with a cutto-pasto (pre-success code).
> ...
> Which will produce instances of Complex, or:
>     class Complex(complex):
>         def __new__(class_, x, y=0.0, polar=False):
>             if polar:
>                 return complex(x * cos(y), x * sin(y))
>             else:
>                 return complex(class_, x, y)
This last line should, of course, be:
                   return complex(x, y)

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



More information about the Python-list mailing list