M
Mike Duffy
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!"
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!"