[Python-Dev] redefining is (original) (raw)

Shane Hathaway shane at zope.com
Tue Mar 23 17🔞37 EST 2004


Tim Peters wrote:

[Andrew Koenig]

... and I wouldn't mind it if there were a way of testing for substitutability that were as easy to spell as "is" -- in fact, I wouldn't mind if it were spelled "is" even though I realize it's probably impractical to do so. It's definitely impractical to do so in the 2.3 line. Looking beyond that, I'm not sure we have real use cases for substitutability. It seemed to boil down to: x substitutable y = x is y if x is mutable, or a mutable object is reachable from x, or y is mutable, or a mutable object is reachable from y x == y otherwise (x and y are immutable, and only immutable objects are reachable from them)

As I understood it, 'b' and 'c' are supposed to be substitutable in the following example, since 'b' and 'c' will have the same value even after 'a' changes:

a = [] b = (a,) c = (a,)

Shane



More information about the Python-Dev mailing list