Legitimate use of the "is" comparison operator?
Mike Duffy
Mike.S.Duffy at gmail.com
Sat Jun 17 03:49:51 EDT 2006
I just recently realized that the comparison operator "is" actually
works for comparing numeric values. Now, I know that its intended use
is for testing object identity, but I have used it for a few other
things, such as type checking, and I was just wondering whether or not
it is considered bad practice in the Python Community to use it for
numerics as well.
Example:
a = range(5)
b = range(5)
if len(a) is len(b):
print "They're the same size!"
else:
print "They're not the same size!"
More information about the Python-list
mailing list