Re: subclassing complex

2008-08-29 Thread BiDi
On Aug 30, 6:18 am, Patrick Maupin <[EMAIL PROTECTED]> wrote: > On Aug 29, 4:24 am, Peter Otten <[EMAIL PROTECTED]> wrote: > > > > > A minimal example is > > > >>> class Complex(complex): > > > ...     def __radd__(self, other): print "radd" > > ...>>> 1j + Complex() > > > 1j > > > versus > > > >>>

Re: subclassing complex

2008-08-29 Thread Patrick Maupin
On Aug 29, 4:24 am, Peter Otten <[EMAIL PROTECTED]> wrote: > A minimal example is > > >>> class Complex(complex): > > ... def __radd__(self, other): print "radd" > ...>>> 1j + Complex() > > 1j > > versus > > >>> class Int(int): > > ... def __radd__(self, other): print "radd" > ...>>> 1 + In

Re: subclassing complex

2008-08-29 Thread Peter Otten
BiDi wrote: > I have been trying to subclass complex, but I am not able to get the > right-hand arithmetic operators working. > > As shown below, if an object of my subclass 'xcomplex' is added on the > right of a 'comlex' object, the type returned is 'complex', not > 'xcomplex'. > > I've tried

Re: subclassing complex

2008-08-29 Thread Patrick Maupin
On Aug 29, 12:17 am, BiDi <[EMAIL PROTECTED]> wrote: > I have been trying to subclass complex, but I am not able to get the > right-hand arithmetic operators working. > > As shown below, if an object of my subclass 'xcomplex' is added on the > right of a 'comlex' object, the type returned is 'compl

subclassing complex

2008-08-28 Thread BiDi
I have been trying to subclass complex, but I am not able to get the right-hand arithmetic operators working. As shown below, if an object of my subclass 'xcomplex' is added on the right of a 'comlex' object, the type returned is 'complex', not 'xcomplex'. I've tried subclassing float and it work