bool behavior in Python 3000?

Miles semanticist at gmail.com
Fri Jul 13 02:45:40 EDT 2007


On Jul 12, 8:37 pm, Alan Isaac <ais... at american.edu> wrote:
> I do not like that bool(False-True) is True.

I've never seen the "A-B" used to represent "A and not B", nor have I
seen any other operator used for that purpose in boolean algebra,
though my experience is limited.  Where have you seen it used?

What's wrong with 'and', 'or', and 'not'?  I think that redefining *,
+, and - to return booleans would only encourage programmers to use
them as shortcuts for standard boolean operations--I'd hate to see
code like this:
>>> if user.registered * (user.age > 13) - user.banned: ...

I don't mind that arithmatic operations are _possible_ with bools, but
I would strongly prefer to see the boolean keywords used for
operations on booleans.

-Miles




More information about the Python-list mailing list