[Python-bugs-list] [ python-Bugs-531355 ] coercian related - complex builtin
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 18 Mar 2002 06:32:27 -0800
Bugs item #531355, was opened at 2002-03-18 09:32
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=531355&group_id=5470
Category: Python Interpreter Core
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Arthur Siegel (aj_siegel)
Assigned to: Nobody/Anonymous (nobody)
Summary: coercian related - complex builtin
Initial Comment:
I had presented this on tutor and python-list:
class Complex(complex):
def __mul__(self,other):
other=Complex(other)
t = complex.__mul__(self,other)
return Complex(t.real,t.imag)
__rmul__ = __mul__
def __add__(self,other):
other=Complex(other)
return Complex(self.real.__add__
(other.real),self.imag.__add__(other.imag))
__radd__ = __add__
Then:
print type(Complex(5,4) * 7)
>><class '__main__.Complex'>
print type(7 * Complex(5,4))
>><class '__main__.Complex'>
print type(Complex(5,4) + 7)
>><class '__main__.Complex'>
But:
print type(7 + Complex(5,4))
>><type 'complex'>
Danny Yoo, after looking into it pretty deeply -
and going to the docs and source gace me this
advice.
"In any case, this is definitely a bug in the
documentation. Arthur, bring
it up on comp.lang.python and Sourceforge again.
Someone should really
look at your example, since it does seem serious... if
not a little
obscure. *grin* "
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=531355&group_id=5470