bool behavior in Python 3000?

Stargaming stargaming at gmail.com
Wed Jul 11 08:04:33 CEST 2007


Steven D'Aprano wrote:
> On Tue, 10 Jul 2007 23:42:01 +0200, Bjoern Schliessmann wrote:
> 
> 
>>Alan G Isaac wrote:
>>
>>
>>>My preference would be for the arithmetic operations *,+,-
>>>to be given the standard interpretation for a two element
>>>boolean algebra:
>>>http://en.wikipedia.org/wiki/Two-element_Boolean_algebra
>>
>>>>>[bool(True+True), bool(True+False)]
>>
>>[True, True]
>>
>>Works for me, or did I misunderstand you?
> 
> 
> It seems to me that you deliberately misunderstood him. Why else would you
> type-cast the integers 2 and 1 to bools to supposedly demonstrate that
> there's nothing wrong with operations between bools returning ints?
[snip]

No, I think Bjoern just wanted to point out that all those binary 
boolean operators already work *perfectly*. You just have to emphasize 
that you're doing boolean algebra there, using `bool()`.
"Explicit is better than implicit."



More information about the Python-list mailing list