[Python-Dev] Re: PEP 285: Adding a bool type

Joshua Macy l0819m0v0smfm001 at sneakemail.com
Wed Apr 3 23:39:48 EST 2002


Ka-Ping Yee wrote:

>
> Guido van Rossum wrote:
> 
>>No.  That would break backwards compatibility.  False==0, and True==1;
>>everything else follows from that.  (But False is not 0, and True is
>>not 1!)
>>
> 
> This is a strange distinction to make -- one that is not made in any
> other programming language i have ever encountered.  Of course *i* get
> it and *you* get it -- but it will be so hard to teach this particular
> weirdness that i consider it fatal to the proposal.
> 
>


   Nobody has any business testing using "is" without a clear 
understanding of object identity (that's its whole purpose)--and with 
that understanding it's blindingly obvious why False is not 0 and True 
is not 1.

If you want weird, try:

 >>> 1 is 1
1
 >>> a = 1
 >>> a is 1
1
 >>> 1001 is 1001
1
 >>> b = 1001
 >>> b is 1001
0


Is it obvious without explanation what's going on here?  Of course not, 
but that doesn't make it a fatal flaw in Python. I don't even believe 
it's hard to teach, but I reiterate that until it's taught new Python 
programmers should avoid testing with "is"--it will bite them almost 
immediately. Stick to == and there aren't any problems.


Joshua




More information about the Python-list mailing list