bool behavior in Python 3000?

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Wed Jul 11 06:46:40 CEST 2007


On Tue, 10 Jul 2007 16:41:58 -0700, Paul Rubin wrote:

> Steven D'Aprano <steve at REMOVE.THIS.cybersource.com.au> writes:
>> Pretending that False and True are just "magic names" for 0 and 1 might
>> be "easier" than real boolean algebra, but that puts the cart before
>> the horse. Functionality comes first: Python has lists and dicts and
>> sets despite them not being ints, and somehow newcomers cope. I'm sure
>> they will cope with False and True not being integers either.
> 
> Are they are aren't they?

I'm sorry, I can't parse that sentence.

> print 1 in [True]
> print 1 == True
> print len(set(map(type, [1, 1])))
> print len(set(map(type, [1, True])))



But I guess that you are probably trying to make the point that True and 
False are instances of a _subtype_ of int rather than ints, under the 
mistaken idea that this pedantry would matter. (If this is not the case, 
then I apologize for casting aspersions.) However, you may notice that I 
said _integers_, which is not the same thing as ints: the Python types 
int and bool are both implementations of the mathematical "integer" or 
"whole number".



-- 
Steven.



More information about the Python-list mailing list