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

rantingrick rantingrick at gmail.com
Sun Jul 11 02:03:40 EDT 2010


On Jul 11, 12:51 am, Stephen Hansen <me+list/pyt... at ixokai.io> wrote:

> You don't need to build a tuple. Just change the tests, to "if
> choiceIdx1 is not None". Its a little more work, sure. But its not
> enough that its even vaguely worth breaking the otherwise very useful
> behavior of bool(0) == False.


Hmm, i beg to differ. The if choice1 is not None and choice2 is not
None is going to run off my screen and into my neighbors backyard
swimming pool!

If you *can* Stefen, show the class a "very useful" case for integer
bool-ing? Please do so, although i doubt you can offer one. Maybe
you'll offer this kinda kludgy stuff...

function(option=1) #instead of True
function(option=0) #instead of False

This is another example of the damage integer booling does to your
code and your mind. What happened to explicit is better than implicit?
What happened to tim toady is a SOB! It is easy to get drawn into this
way of coding and very hard to pull out. And it's wrong, wrong, wrong.
NEVER substitute 1 for True and/or 0 for False! NEVER! This is anti
Pythonic!

py> import this



More information about the Python-list mailing list