Suggestions for good programming practices?
Mark McEahern
marklists at mceahern.com
Mon Jun 24 16:22:01 EDT 2002
Dianne van Dulken wrote:
> I'm fairly new to python, coming from a perl background, and was wondering
> if anyone has a list of things that they consider as good programming
> practice in Python (I thought this might be an interesting topic for
> discussion, anyway)
Here's one...
When evaluating whether a variable is None, don't compare it like this:
if x == None:
instead, use:
if x:
or:
if not x:
The encourages a polymorphic approach. If you must compare to None, use the
identify operator rather than equality:
if x is None:
or:
if x is not None:
// mark
-
More information about the Python-list
mailing list