'if name is not None:' v. 'if name:'

Victor Noagbodji noagbodjivictor at gmail.com
Tue Jul 15 15:44:25 EDT 2008


>>what's the difference between these two statement?
>one checks if the given object is not None, the other checks if it's a true value:
>http://docs.python.org/ref/Booleans.html#Booleans
>>And which one should one use?
>depends on what you want to test for, of course.
>
></F>

Well that's exactly why I'm asking. Since None returns False in if
statements. Why do people use if name is not None: instead of simply
writing if not name?

-- 
NOAGBODJI Paul Victor



More information about the Python-list mailing list