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/2004-March/043324.html below:

[Python-Dev] redefining is

[Python-Dev] redefining isAndrew Koenig ark-mlist at att.net
Fri Mar 19 15:08:45 EST 2004
> > By "object equivalence", I mean mutual substitutability--which is the
> same
> > as identity for mutable objects, but not for immutable ones.
> 
> So what does it mean for immutable objects?

Two immutable objects are equivalent if and only if they have the same type
and all of their attributes are (recursively) equivalent.

> Your raise/except example is bad.  Do you have another one in which
> people could not just use '==' instead of 'is'?

x = ([], [])
y = ([], [])

Here, x == y is true, but x and y are not equivalent.  We can prove this
inequivalence by executing x[0].append(42) and noting that y[0] does not
change.

a = []
b = []
x = (a, b)
y = (a, b)

Here, x == y is true, and x and y are equivalent.


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