On Fri, 01 Oct 2010 11:23:25 -0700, John Nagle wrote:

>> Why so ? The doc clearly states that booleans are integers with True ==
>> 1 and False == 0, so there's nothing implicit here.
> 
>      Python "bool" values are NOT integers.  They can be coerced to
> integers for historical reasons.  

Incorrect. bools *are* ints in Python, beyond any doubt.

>>> isinstance(True, int)
True

True and False are instances of int. That's all you need to know.


> But "str(True)" is "True".

I assume that you're not comparing the literal strings "str(True)" and 
"True" (which would make your claim incorrect). Nevertheless, leaving out 
the quotes is also incorrect:

>>> str(True) is True
False

The only way to get your claim to work is to mix'n'match quotation marks, 
leaving one pair in and dropping the other:

>>> str(True) is "True"
True

But so what? What do you think that proves? All it shows is an 
implementation detail to do with caching of certain small strings:

>>> str(5) is "5"
True



-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to