首页 > 代码库 > Python None comparison: should I use “is” or ==?

Python None comparison: should I use “is” or ==?

Use is when you want to check against an object‘s identity (e.g. checking to see if var is None). Use == when you want to check equality (e.g. Is var equal to 3?).

 

 

ref: http://stackoverflow.com/questions/14247373/python-none-comparison-should-i-use-is-or

Python None comparison: should I use “is” or ==?