integer >= 1 == True and integer.0 == False is bad, bad, bad!!!

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sun Jul 11 20:23:40 EDT 2010


On Sun, 11 Jul 2010 16:22:41 -0700, rantingrick wrote:

> On Jul 11, 1:19 pm, Mark Dickinson <dicki... at gmail.com> wrote:
> 
>> Okay.  What fix do you propose?  Would your fix maintain the identity
>> "0 == False"?
> 
> No because all integers should bool True. An integer is a value that IS
> NOT empty 

Integers aren't containers, the concept of "empty" or "full" doesn't 
apply to them.

> and IS NOT None. 

By this definition, the string "rantingrick hasn't thought this through" 
is an integer. It's not empty, and not None, so therefore an integer by 
your definition.

Possibly the integer two-thirds of the way between 3 and 4.


> Therefore the only logical way to handle
> integer bool-ing is to say they are all True.

For some definition of "logical".


>> For bonus points, explain how you'd deal with any backwards
>> compatibility problems that your fix introduces.
> 
> We would't deal with backwards compatibility as this notion of bool(1)
> == True and bool(0) == False if backwards way of thinking. Sure it saves
> a few keystrokes but in the end only serves to obfuscate the code and
> promote bad programming styles. WE SHOULD NEVER BE USING 1 IN PLACE OF
> True AND 0 IN PLACE OF False!

Nevertheless, what is done is done, and now you have to deal with it. 
Just wishing that it was never done is not dealing with backwards 
compatibility, and breaking existing code is not an acceptable option.

So if your plan is to refuse to deal with existing code, I am very glad 
indeed that your plan will go absolutely nowhere.


>> Have you considered forking Python?  That may be the way forward here.
> 
>  I have considered this many times in the past and continue to
> consider it even today. 

Please do. I think that this will be the best thing for the Python 
community.



-- 
Steven



More information about the Python-list mailing list