A RetroSearch Logo

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

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2009-September/091998.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 implementationsNick Coghlan ncoghlan at gmail.com
Wed Sep 23 14:09:13 CEST 2009
Greg Ewing wrote:
> Willem Broekema wrote:
> 
>> 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).
> 
> How does this work at the C typeslot level, where
> there are no __rop__ methods?

The interpreter doesn't promise to call those slots with "self" first -
self will be the second argument in the "rop" case.

See binary_op1() in abstract.c for the gory details (I had to go look it
up myself in order to rediscover how it worked).

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia
---------------------------------------------------------------
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