Suggestions for good programming practices?

David LeBlanc whisper at oz.net
Mon Jun 24 16:44:04 EDT 2002


David LeBlanc
Seattle, WA USA

> -----Original Message-----
> From: python-list-admin at python.org
> [mailto:python-list-admin at python.org]On Behalf Of Mark McEahern
> Sent: Monday, June 24, 2002 13:22
> To: python-list at python.org
> Subject: RE: Suggestions for good programming practices?
>
>
> 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
>

I'm curious to know how this encourages polymorphism, and how making a
conditional test implicit rather then explicit is good practice?

Regards,

Dave LeBlanc
Seattle, WA USA






More information about the Python-list mailing list