[Python-Dev] redefining is
ark-mlist at att.net
Fri Mar 19 15:02:54 EST 2004
> But this mutual substitutability is context dependant.
> "is" guarantees that both objects are mutual substitutable in
> *any* context. "==" defines the mutual substitutability for the
> "default" context. Any other context is application dependant,
> so the comparison function should be defined by the application.
I disagree: There are some contexts that are already written into the
Python language--a fact that gives those contexts a status beyond mere
application dependence. In particular, the language says that when you use
a particular string literal in a program, you may or may not get the same
object, but if you get two different objects, there will be no way to
distinguish those objects from each other without examining their identity.
That is not a notion I made up, nor is it dependent on any particular
application. It's already part of Python.
So what I'm claiming is that there should be a way of asking: Given two
objects, is there any way to distinguish them aside from their identity? I
further claim that in many cases, people mistakenly use "is" as a way of
asking this question, partly because there is no easy way to ask it now.
More information about the Python-Dev