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/135326.html below:

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

[Python-Dev] == on object tests identity in 3.xBenjamin Peterson benjamin at python.org
Mon Jul 7 17:15:47 CEST 2014
On Mon, Jul 7, 2014, at 04:22, Andreas Maier wrote:
> While discussing Python issue #12067 
> (http://bugs.python.org/issue12067#msg222442), I learned that Python 3.4 
> implements '==' and '!=' on the object type such that if no special 
> equality test operations are implemented in derived classes, there is a 
> default implementation that tests for identity (as opposed to equality 
> of the values).
> 
> The relevant code is in function do_richcompare() in Objects/object.c.
> 
> IMHO, that default implementation contradicts the definition that '==' 
> and '!=' test for equality of the values of an object.
> 
> 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?

% python
Python 2.7.6 (default, May 29 2014, 22:22:15) 
[GCC 4.7.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> class x(object): pass
... 
>>> class y(object): pass
... 
>>> x != y
True
>>> x == y
False
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