[Python-Dev] redefining is
ark-mlist at att.net
Fri Mar 19 13:03:24 EST 2004
> I understand your argument, and have some sympathy for it, but I don't
> think that 'is' should be the way to spell object equivalence. If
> someone asks "Tim is Barry" I would expect they want an identity test,
> not an equivalence test, otherwise they might not get the geezin' Python
> hacker they wanted even though as bass players and Britney Spears
> fanatics, we're completely substitutable.
If Tim and Barry are mutable, then an identity test is what they get.
> IIRC, id() has problems on Jython also, so relying on that for identity
> doesn't seem right either.
> Also, since we don't really know what "object equivalence" means in a
> practical sense, I don't know what we'd be spelling. But if we do
> figure it out (and can explain it in a way people can understand it),
> and find that it's an important enough concept to want to express, we'd
> need a Different Way to spell it in Python.
I think I know what object equivalence means in a practical sense:
It means the same thing as object identity unless both objects are
immutable, in which case it is true if and only if the objects have the same
type and all of their corresponding attributes are (recursively) equivalent.
> To me, "is" asks "are these
> two things the same thing" not "could these two things serve the same
> purpose". An English word (not mathematical symbol) was chosen for this
> concept for a reason.
Understood. The thing is that some people expect expressions such as
"Hello" is "Hello"
to yield True under all circumstances, and they don't.
> Maybe we need a 'like' keyword-let to spell equivalence:
> >>> "hello" is like 'hello'
> PS: 'raise "quit"' doesn't really enter into this for two reasons.
> First, string exceptions are going away. Second, there's no 'is'
> there. If string exceptions were to stick around, then it might make
> sense to redefine the match criteria in terms of object equivalence.
> But that's a moot point.
Out of curiosity, why are string exceptions going away? Just to insist that
people give explicit types to their exceptions?
More information about the Python-Dev