Mike Orr wrote:
> On 1/1/07, Guido van Rossum <[EMAIL PROTECTED]> wrote:
>> On 1/1/07, James Thiele <[EMAIL PROTECTED]> wrote:
>>> PEP 3100 states:
>>> None becomes a keyword [4] (What about True, False?)
>>>
>>> Has a decision been made?
>> No, but I think the argument for making True/False reserved words is
>> pretty weak.
>>
>>> Also a bool acts like an int in various contexts. For example:
>>>>>> True == 1
>>> True
>>>>>> False == 0
>>> True
>>>>>> 16 + (0 == 0)
>>> 17
>>>
>>> Will this behavior continue?
>> Yes. Don't confuse Python with Java.
> 
> Huh?  'True == 1' is a "feature"?  '16 + (0 == 0)' being illegal is a
> "Javaism"?  Would somebody care to explain this?  It's acceptable that
> 2 is true but not True?  Why do we need 1 for True at all if we have
> True?

None of the above examples are inconsistent with boolean algebra combined with 
pythons practice of promoting types in various situations.  Since bool is a 
subclass of int, it doesn't need promoting to int in these cases, but the 
results would be the same.

    http://www.allaboutcircuits.com/vol_4/chpt_7/2.html


The only place (I know of) where it seems out of order would be examples like...

    >>> True + True
    2
    >>> True == (True + True)
    False

Here the result of the addition two bools is an int instead of being a bool.


The AbstractBaseClass wiki has questions concerning where bool is in the class 
tree.  It shows bool as *not* being a subclass of int.

     http://wiki.python.org/moin/AbstractBaseClasses


So would adding two bools return an int or a bool if this is changed?

Should Bool be a subclass of Numeric instead of object?


The way python uses bools makes me think maybe the relationship between 
integers 
and bools should be reversed.  An integer could be a subclass of bool.  Then 
all 
positive integers, would also be equal to True.  But that would change the 
behavior of adding integers and bools, because the result would be either a 
True 
or False instead of an int because the int would be promoted to bool instead of 
the bool being (like promoted to) an int.

Cheers,
    Ron



_______________________________________________
Python-3000 mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000
Unsubscribe: 
http://mail.python.org/mailman/options/python-3000/archive%40mail-archive.com

Reply via email to