Overloading operators on the rigth.

Andrew Durdin adurdin at gmail.com
Thu Oct 14 19:55:59 EDT 2004


On Thu, 14 Oct 2004 20:27:13 GMT, Bengt Richter <bokr at oz.net> wrote:
> 
> BTW, I experimented a little further with NotImplemented and the gt,cmp,coerce
> methods in a base class vs derived and it looks like the search prefers
> a base class gt or cmp over a derived version of the next alternative.

Isn't this just a side-effect of the attribute lookup order? When
looking for __gt__, python'll check the class, then go through the
base classes, and only return AttributeError if it's not found in the
class or any of its bases; after which it tries __cmp__ etc.

Am I understanding this correctly?



More information about the Python-list mailing list