easy question on parsing python: "is not None"
Terry Reedy
tjreedy at udel.edu
Mon Aug 9 12:28:17 EDT 2010
More information about the Python-list mailing list
Mon Aug 9 12:28:17 EDT 2010
- Previous message (by thread): easy question on parsing python: "is not None"
- Next message (by thread): easy question on parsing python: "is not None"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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 STANDARD IDIOM. > 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 different. > 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
- Previous message (by thread): easy question on parsing python: "is not None"
- Next message (by thread): easy question on parsing python: "is not None"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list