bool behavior in Python 3000?

Ben Finney bignose+hates-spam at benfinney.id.au
Wed Jul 11 03:18:56 CEST 2007


Steven Bethard <steven.bethard at gmail.com> writes:

> It's much easier to explain to newcomers that *, + and - work on
> True and False as if they were 1 and 0 than it is to introduce them
> to a two element boolean algebra.

I've found exactly the opposite. When explaining that None is a value
that is not equal to any other, and that is a useful property, I've
received little confusion. Whereas when someone discovers that
arithmetic works on True and False as if they were numbers, or that
they are in fact *equal to* numbers, their function as boolean values
is much harder to explain.

So, it's for the purposes of explaining True and False to newcomers
(let alone keeping things clear when observing a program) that I would
welcome True and False as discrete values, so that when those values
are produced by an expression or function the result is clearly a
boolean value and not a faked one that is "really" an integer.

-- 
 \        "Pinky, are you pondering what I'm pondering?" "Wuh, I think |
  `\   so, Brain, but wouldn't anything lose its flavor on the bedpost |
_o__)                            overnight?"  -- _Pinky and The Brain_ |
Ben Finney



More information about the Python-list mailing list