[Python-Dev] A proposal has surfaced on comp.lang.python toredefine "is"

Andrew Koenig ark-mlist at att.net
Wed Mar 17 19:46:09 EST 2004


> I'm curious what the reason is to want to redefine 'is' for
> immutables.  If I understand Andrew, it's fix broken programs after
> the fact (almost as if by time machine :-).
> 
> It seems to me that 'is' should never be used for immutables except
> for singletons like None.  Perhaps PyChecker should warn about
> inappropriate use of 'is' to compare two immutable objects, unless one
> of them is None?  This would be a cheaper solution than changing the
> implementation.

It wasn't my proposal, so I don't know the reason.  However, I suspect that
one motivation is just what you observed: "is" isn't a real good idea for
immutables.  One of the people in the comp.lang.python discussion suggested
that with the change, "is" would be equivalent to "is substitutable for".
Right now, "x is y" implies that x is substitutable for y, but the reverse
is not always true.

My own concern is that if someone writes expressions such as "x is 0" by
mistake, the resulting program might always work on one implementation but
fail on another.





More information about the Python-Dev mailing list