[Python-ideas] Programming recommendations (PEP 8) and boolean values
bruce at leapyear.org
Wed Aug 8 19:27:19 CEST 2012
On Wed, Aug 8, 2012 at 9:59 AM, Oleg Broytman <phd at phdru.name> wrote:
> On Thu, Aug 09, 2012 at 02:18:53AM +1000, Ben Finney <
> ben+python at benfinney.id.au> wrote:
> > What is a compelling use case for checking precisely for True or False?
> To distinguish False and None for a tri-state variable that can have
> 3 values - "yes", "no" and "unspecified" - True, False and None in
I'd probably write that this way:
if t is None:
# not specified
on the other hand, if I had a variable that could be either a number or
True/False, I would probably write:
if t is True:
elif t is False:
# use t as a number
just as I would for any other singleton value. Why does the PEP say that ==
True is preferred to is True?
Follow me: http://www.twitter.com/Vroo http://www.vroospeak.com
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas