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/2014-July/135330.html below:

[Python-Dev] == on object tests identity in 3.x

[Python-Dev] == on object tests identity in 3.xAndreas Maier andreas.r.maier at gmx.de
Mon Jul 7 17:29:54 CEST 2014
Am 07.07.2014 17:15, schrieb Benjamin Peterson:
> On Mon, Jul 7, 2014, at 04:22, Andreas Maier wrote:
>>
>> Python 2.x does not seem to have such a default implementation; == and
>> != raise an exception if attempted on objects that don't implement
>> equality in derived classes.
>
> Why do you think that?

Because I looked at the source code of try_rich_compare() in object.c of 
the 2.7 stream in the repository. Now, looking deeper into that module, 
it turns out there is a whole number of variations of comparison 
functions, so maybe I looked at the wrong one.

Instead of trying to figure out how they are called, it is probably 
easier to just try it out, as you did. Your example certainly shows that 
== between instances of type object returns a value.

So the Python 2.7 implementation shows the same discrepancy as Python 
3.x regarding the == and != default implementation.

Does anyone know why?

Andy


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