easy question on parsing python: "is not None"

Nobody nobody at nowhere.com
Mon Aug 9 16:56:09 CEST 2010

On Mon, 09 Aug 2010 04:41:23 -0700, saeed.gnu wrote:

> "x is not None"  is a really silly statement!! because id(None) and id
> of any constant object is not predictable! I don't know whay people
> use "is" instead of "==". you should write "if x!=None" instead of "x
> is not None"

No, you should use the identity check. If you use ==, the operand
may have an __eq__ or __cmp__ method which considers the object equal to

More information about the Python-list mailing list