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

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

[Python-Dev] == on object tests identity in 3.x - summaryAndreas Maier andreas.r.maier at gmx.de
Tue Jul 8 01:53:06 CEST 2014
Thanks to all who responded.

In absence of class-specific equality test methods, the default 
implementations revert to use the identity (=address) of the object as a 
basis for the test, in both Python 2 and Python 3.

In absence of specific ordering test methods, the default 
implementations revert to use the identity (=address) of the object as a 
basis for the test, in Python 2. In Python 3, an exception is raised in 
that case.

The bottom line of the discussion seems to be that this behavior is 
intentional, and a lot of code depends on it.

We still need to figure out how to document this. Options could be:

1. We define that the default for the value of an object is its 
identity. That allows to describe the behavior of the equality test 
without special casing such objects, but it does not work for ordering. 
Also, I have difficulties stating what constitutes that default case, 
because it can really only be explained by referring to the presence or 
absence of the class-specific equality test and ordering test methods.

2. We don't say anything about the default value of an object, and 
describe the behavior of the equality test and ordering test, which both 
need to cover the case that the object does not have the respective test 
methods.

It seems to me that only option 2 really works.

Comments and further options welcome.

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