Implicit conversion to boolean in if and while statements
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Mon Jul 16 04:05:16 EDT 2012
On Sun, 15 Jul 2012 19:41:34 -0700, Ranting Rick wrote:
> Short circuitry is a powerful tool! But why the heck would your
> sequences ever be None? Are you using None as a default? And if so, why
> not use an empty sequence instead ([], {}, "")?
Mostly for explicitness. I want to be able to say that there is
*explicitly* no seq, not merely that it happens to be a list which right
now is empty but later might not be. Using None for missing values is
idiomatic Python.
You should approve, if only for the sake of consistency: None is meant to
be used as "no such value", and that's exactly how I am using it, even at
the cost of my convenience when writing the code.
--
Steven
More information about the Python-list
mailing list