Subclassing complex with computed arguments

Peter Olsen pcolsen at comcast.net
Thu Nov 25 17:30:18 EST 2004


I want to define a class "point" as a subclass of complex.  

When I create an instance 

sample = point(<arglist>) 

I want "sample" to "be" a complex number, but with its real and
imaginary parts computed in point()'s __init__ function with their
values based on the arglist.  I want to compute with point instances
as though they were native complex numbers, but I want to be able to
define some new methods and over-ride some of complex's existing ones.

This is probably very simple, but it hasn't been simple to me.

Please feel free to flame me with RTFM as long as you also tell me
where in TFM to R.

If you respond, please send a copy directly to me.  I seldom have
access to this group.  (My primary network isn't connected to the
internet.)

Peter
pcolsen-at-comcast.net



More information about the Python-list mailing list