PEP 285: Adding a bool type

Bernard Yue bernie at 3captus.com
Tue Apr 2 05:51:40 EST 2002


Hi Guido,

Guido van Rossum wrote:
 
>     1) Should this PEP be accepted at all.
> 

Thought it was decided.  Since it is not.  I cast my vote as +1.

When I first saw the subject on python-dev, I don't like it, due to
backward compatabilty issue.  I change my mind, after reading the PEP
and most of the discussion.  The PEP actually keep the impact to
minimal.

I believe a computer language do need a boolean datatype.  It is needed
because some people see a half glass of water as half full and other see
it as half empty.  0 and 1 is not precise enough.  Acutally, I was
surprised to find that Python has None and Mapping type, but not Bool,
when I first pick up the language.  BTW, I vote for 'bool' as class
name.

>     2) Should str(True) return "True" or "1": "1" might reduce
>        backwards compatibility problems, but looks strange to me.
>        (repr(True) would always return "True".) 

str(True) should return 'True' because 2 is ture too.  But I can live
with '1' as well.

>     3) Should the constants be called 'True' and 'False'
>        (corresponding to None) or 'true' and 'false' (as in C++, Java
>        and C99).

'True' and 'False' for consistency.
 
>     Most other details of the proposal are pretty much forced by the
>     backwards compatibility requirement; e.g. True == 1 and
>     True+1 == 2 must hold, else reams of existing code would break.
> 

Don't like True + 1 == 2, but we are living in an imperfect world.

>     Minor additional issues:
> 
>     4) Should we strive to eliminate non-Boolean operations on bools
>        in the future, through suitable warnings, so that e.g. True+1
>        would eventually (e.g. in Python 3000 be illegal).  Personally,
>        I think we shouldn't; 28+isleap(y) seems totally reasonable to
>        me.
> 

I think we should if in Python 3000, x == False returns true when x is
false.

>     5) Should operator.truth(x) return an int or a bool.  Tim Peters
>        believes it should return an int because it's been documented
>        as such.  I think it should return a bool; most other standard
>        predicates (e.g. issubtype()) have also been documented as
>        returning 0 or 1, and it's obvious that we want to change those
>        to return a bool.
>

I prefer operator.truth(x) returns bool.
  

Bernie

-- 
In ancient England a person could not have sex unless you had consent of 
the King (unless you were in the Royal Family). When anyone wanted to
have a 
baby, they got consent of the King, the King gave them a placard that
they 
hung on their door while they were having sex. The placard had 
F.*.*.*. (Fornication Under Consent of the King) on it. 

Now you know where that came from.



More information about the Python-list mailing list