easy question on parsing python: "is not None"

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Aug 9 22:14:26 CEST 2010

En Mon, 09 Aug 2010 08:41:23 -0300, saeed.gnu <saeed.gnu at gmail.com>  

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

No; consider this:

py> id([])==id([])
py> [] is []

Comparing id's is the same as using the is operator only if you can  
guarantee that both operands are alive at the same time.

Gabriel Genellina

More information about the Python-list mailing list