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

rantingrick rantingrick at gmail.com
Sun Jul 11 04:15:51 EDT 2010


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

> Nonsense.
>
> Prove it. Show actual benchmarks and actual problems to that style.

I can't believe i actually have to prove to you that creating a tuple
and then testing for bool-inity takes more time than just the bool
test, but here goes *another* Sunday school lesson...

>>> s1 = "if (a, b) != (None, None):\n    pass"
>>> t1 = timeit.Timer(s1, 'a=1;b=1')
>>> min(t1.repeat())
0.23950232000015603
>>> s2 = "if a is not None and b is not None:\n    pass"
>>> t2 = timeit.Timer(s2, 'a=1;b=1')
>>> min(t2.repeat())
0.14334155999995346

> Tests that do, in essence, "if whatever in (constant1, constant2)" are
> exceedingly common. The burden is on you to prove they are bad. With
> real data.

yea, been there done that.

> And yes, I do consider mangling my name to be an insult.

obviously i sounded out your name in my head. It is getting pretty
late here after all so give me break for crying out loud.

> 1 is something.

Yes, but not necessarily a "True" something!

> 0 is nothing.

Yes, but not necessarily a "False" nothing!

What is a True "something" and what is a False "nothing" Stephen? Put
that one up where it belongs with the chicken and the egg where it
belongs -- next to the toilet with Hustler and Time.

> My statement is neither FUD, nor even an ad hominem attack. If you
> dispute my dismissal, show evidence. Any will do.
>
> Oh, I do admit that in the end, I did venture into the ad hominem area
> where I called into question your attitude and general behavior

haha, i love how you denied the fact that you used ad hominem attacks
and then directly after that tried to makes excuses for the very
behavior you denied. Clinton made a career out this very same story
telling. Nice work Bill Jr. *wink*

> Do you see the pattern? Every fundamental data type has a "nothing"
> state: and they ALL evaluate as false in conditionals.
>
> Why should integers be any different? Because, uh, you say so.

No because i provide a very good reason --specifically in the case of
a conditional bool-ing-- that integers bool-ing to True/False can be
disastrous. And not only did i provide one reason, i provided two. The
second being that 1/0 as compared to True/False is misleading in it's
intention.  Which renders code less readable, and supports bad
programming styles.




More information about the Python-list mailing list