Suggestions for good programming practices?
Chris Barker
Chris.Barker at noaa.gov
Tue Jun 25 12:19:08 EDT 2002
Aahz wrote:
> Depends on what you're testing for.
Exactly. I hardly ever use None to mean false, I tend to use it to mean,
well, "none", or nothing there, as it a value that is not defined yet or
doesn't exist.
> object model is that any "empty" object tests as false: None, 0, "", (),
> [], and {}.
That's part of the problem for me, when I am using numbers, 0 (or 0.0)
is as often as not a perfectly valid number, and should not be
interpreted as false. However as someone mentioned:
if x is None
is preferabale to
if x == None
What you want to know is whether x is bound to None so that's what you
should check for.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
More information about the Python-list
mailing list