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

posted @ 2016-12-27 12:33  圆旭  阅读(206)  评论(0)    收藏  举报