[Python-Dev] redefining is
Phillip J. Eby
pje at telecommunity.com
Fri Mar 19 17:57:09 EST 2004
At 05:40 PM 3/19/04 -0500, Andrew Koenig wrote:
>Nevertheless, I still wish that expressions such as "x is 'foo'" did not
>silently differ in outcome from one implementation to another.
The part that drives me nuts about this discussion is that in my view, "x
is 'foo'" has the *same* outcome on all implementations. That is, it's
true if x refers to that exact string object.
The thing that's different from one implementation to the next is whether
there's any chance in hell of x being that same 'foo' string. But to me,
that 'foo' string looks like a *newly created* string, so to the naive
glance there's no possible way that it could be the same object. In other
words, it looks like a bad expression to use in the first place: one that's
guaranteed to be false, except by accident of implementation.
So, I have trouble understanding how it is that somebody could get to a
place where they think that using 'is' for strings and numbers is a good
idea in the first place. But then, I read the entire Python language
reference (and a good chunk of the library reference) before I tried
writing even a single line of Python code, so I can imagine that my
perspective on this might not be the most common one. :)
More information about the Python-Dev