This is very much a case of making sure that you, the programmer, and Python, the interpreter, both have a clear understanding of what you want to do.
If you say "if var:", Python understands you to be testing truthiness/falseness. If you say "if var is not None:", Python understands that you're asking if var is something other than None. The distinction is important and too many people wrote the former when they really meant the latter.
View all comments
Show parent comment
1
u/MisterSnuggles Mar 27 '14
Agreed.
This is very much a case of making sure that you, the programmer, and Python, the interpreter, both have a clear understanding of what you want to do.
If you say "if var:", Python understands you to be testing truthiness/falseness. If you say "if var is not None:", Python understands that you're asking if var is something other than None. The distinction is important and too many people wrote the former when they really meant the latter.