easy question on parsing python: "is not None"
tjreedy at udel.edu
Mon Aug 9 18:28:17 CEST 2010
On 8/9/2010 7:41 AM, saeed.gnu 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!!
Wrong. It is exactly right when that is what one means and is the
> because id(None) and id
> of any constant object is not predictable!
This is silly. The id of None and of any other object are predictably
> I don't know whay people use "is" instead of "==".
Because it is the right thing to do!
> you should write "if x!=None" instead of "x is not None"
Wrong. It is trivial to make a class whose objects compare == to None.
Terry Jan Reedy
More information about the Python-list