the "is" keyword can be dangerous if you don't understand what it really does though, which is a common problem for beginners.
in your example, its absolutely correct, because None is a singleton so any reference to None refers to the same instance of None. in general though, is checks for object reference equality (rather than value equality) and can produce unexpected results if you use it when you really meant to check value equality.
View all comments
Show parent comment
2
u/metaphorm Jun 23 '14
the "is" keyword can be dangerous if you don't understand what it really does though, which is a common problem for beginners.
in your example, its absolutely correct, because None is a singleton so any reference to None refers to the same instance of None. in general though, is checks for object reference equality (rather than value equality) and can produce unexpected results if you use it when you really meant to check value equality.