Victor Noagbodji wrote:

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?

Because they want to distinguish between None and other values that evaluate to False, of course. As the page I linked to explains, there are many objects that evaluate to false in a boolean context; None is just one of them.

Or to spell it out: if you need to distinguish between None and other false values, use an explicit test. If you don't need to distinguish between None and other false values, don't use an explicit test.

</F>

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to