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

Jeffrey Froman jeffrey at fro.man
Tue Jul 15 15:50:50 EDT 2008


Victor Noagbodji wrote:

> Why do people use if name is not None: instead of simply
> writing if not name?

To differentiate from the case where name == '', or some other non-None
false value. So the question is, do you want to test for identity with
None, or for truth in general?


Jeffrey



More information about the Python-list mailing list