confusion with __add__ and __radd__
Terry Hancock
hancock at anansispaceworks.com
Tue Dec 3 16:32:01 EST 2002
Walter Moreira wrote:
> Hello. I'm confused about the behavior of the 'reverse' methods
> __radd__, __rmul__, etc, and Google didn't help me.
[...]
>
> Why isn't the __radd__ method called, since __add__ returns
> 'NotImplemented'? If 'Foo' is a classic class it works ok. Am I
> overlooking something obvious?
AFAIK, __radd__ is being phased out, starting in 2.2 (the whole series of
"reversed" operators). I don't really understand the new syntax (not sure I
fully understood the old one), but this would explain why "newstyle"
classes wouldn't have implemented it. My guess is that the newer classes
make it unnecessary in some way. You'll want to look at the Python 2.2
release notes I think.
Cheers,
Terry
--
Anansi Spaceworks
http://www.anansispaceworks.com
More information about the Python-list
mailing list