A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2009-September/091957.html below:

[Python-Dev] operator precedence of __eq__, __ne__, etc, if both object have implementations

[Python-Dev] operator precedence of __eq__, __ne__, etc, if both object have implementationsWillem Broekema metawilm at gmail.com
Tue Sep 22 17:23:03 CEST 2009
On Tue, Sep 22, 2009 at 5:12 PM, Mark Dickinson <dickinsm at gmail.com> wrote:
> - Exception to the previous item: if the left operand is an instance
> of a built-in type or a new-style class, and the right operand is an
> instance of a proper subclass of that type or class AND overrides the
> base’s __rop__() method, the right operand’s __rop__() method is tried
> before the left operand’s __op__() method.

The AND above (which I uppercased) is subtle but important. In the "x
op y" case with y being of a subclass of the class of x, if there is
no class in between x and y (excluding x, including y) that overrides
the __rop__ method, then y,__rop__(x) is *not* tried before
x.__op__(y).

It's easy for other implementations to get this wrong. :)

- Willem
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4