Legitimate use of the "is" comparison operator?

Mike Duffy Mike.S.Duffy at gmail.com
Sat Jun 17 09:49:51 CEST 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.


a = range(5)
b = range(5)

if len(a) is len(b):
    print "They're the same size!"
    print "They're not the same size!"

More information about the Python-list mailing list