> > 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.
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