bool behavior in Python 3000?

Steve Holden steve at holdenweb.com
Wed Jul 11 14:23:32 CEST 2007


Steven D'Aprano wrote:
> 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".
> 
You can only cast aspersions in C, C# and similar languages. In Python 
you'd have to explicitly convert the aspersions to some other type ;-)

regards
  Steve
-- 
Steve Holden        +1 571 484 6266   +1 800 494 3119
Holden Web LLC/Ltd           http://www.holdenweb.com
Skype: holdenweb      http://del.icio.us/steve.holden
--------------- Asciimercial ------------------
Get on the web: Blog, lens and tag the Internet
Many services currently offer free registration
----------- Thank You for Reading -------------




More information about the Python-list mailing list