easy question on parsing python: "is not None"

saeed.gnu saeed.gnu at gmail.com
Mon Aug 9 14:11:11 CEST 2010


On Aug 9, 3:41 pm, "saeed.gnu" <saeed.... at gmail.com> wrote:
> "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)"
>
> "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"

Although small objects are unique in the memory (with a unique id) and
using "is" works ok, but that's not logical to compare id's when we
actually want to compare values!



More information about the Python-list mailing list