[Python-Dev] redefining is (original) (raw)
Andrew Koenig ark-mlist at att.net
Fri Mar 19 15:08:45 EST 2004
- Previous message: [Python-Dev] redefining is
- Next message: [Python-Dev] redefining is
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> 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.
- Previous message: [Python-Dev] redefining is
- Next message: [Python-Dev] redefining is
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]