bool behavior in Python 3000?

Ben Finney bignose+hates-spam at benfinney.id.au
Thu Jul 12 08:53:17 EDT 2007


"Terry Reedy" <tjreedy at udel.edu> writes:

> In Guido's opinion (and mine, but his counts 100x), the positive
> benefits of the current implementation are greater than the net
> positive benefits of a 'pure' type.  See
>
> http://www.python.org/dev/peps/pep-0285/

I assume you're referring to:

    6) Should bool inherit from int?

    => Yes.

       In an ideal world, bool might be better implemented as a
       separate integer type that knows how to perform mixed-mode
       arithmetic.  However, inheriting bool from int eases the
       implementation enormously [...further explanation...]

I accept Guido's explanation in the PEP, that the implementation is
made much easier, as an explanation of why bool inherits from int. I
haven't seen people here expressing that they want the opposite.

To my mind the more fundamental issue is this one:

    4) Should we strive to eliminate non-Boolean operations on bools
       in the future, through suitable warnings, so that for example
       True+1 would eventually (in Python 3000) be illegal?

    => No.

       There's a small but vocal minority that would prefer to see
       "textbook" bools that don't support arithmetic operations at
       all, but most reviewers agree with me that bools should always
       allow arithmetic operations.

Frustratingly, unlike the above point about inheritance, the PEP gives
no explanation of why the answer to this is "No". All we get is "most
reviewers agree", with no explanation of *why*.

So, I'm left with the points already made in this thread as to why the
answer should be "yes", and no source online for an official
explanation of the "no".

-- 
 \          "I don't like country music, but I don't mean to denigrate |
  `\          those who do. And for the people who like country music, |
_o__)                     denigrate means 'put down'."  -- Bob Newhart |
Ben Finney



More information about the Python-list mailing list