"is" and "=="

Carl Banks imbosol-1047407749 at aerojockey.com
Tue Mar 11 13:45:19 EST 2003


Thomas Wouters wrote:
> There are very few uses of 'is' in normal user code...
> (much like 'from module import *' :)

That's just not true.  There are real reasons in normal user code to
test the identity of an object, and not just against singletons like
None.

Want to search a deeply-nested list for a particular object (which
might itself be a deeply nested list)?  It happens.  Use is.  Assert
that an object is its child's parent in a heirarchy?  Use is.

It's uncommon, but there are more than a few good uses for is.


-- 
CARL BANKS




More information about the Python-list mailing list