easy question on parsing python: "is not None"

Ben Finney ben+python at benfinney.id.au
Tue Aug 10 03:18:35 CEST 2010


"saeed.gnu" <saeed.gnu at gmail.com> writes:

> "x is y"          means   "id(y) == id(y)"
> "x is not y"      means   "id(x) != id(x)"
> "x is not None"   means   "id(x) != id(None)"

No, the meanings are different. The behaviour might, or might not, be
the same. The operators are different *because* the meanings are
different.

> "x is not None"  is a really silly statement!! because id(None) and id
> of any constant object is not predictable!

The value returned from ‘id’ is not predictable; but it doesn't need to
be predictable. It merely needs to obey the invariant that the identity
of any given object won't change during the object's lifetime.

-- 
 \       “You've got the brain of a four-year-old boy, and I'll bet he |
  `\                         was glad to get rid of it.” —Groucho Marx |
_o__)                                                                  |
Ben Finney



More information about the Python-list mailing list