integer >= 1 == True and integer.0 == False is bad, bad, bad!!!
Michael Torrie
torriem at gmail.com
Tue Jul 13 01:31:45 EDT 2010
On 07/12/2010 06:36 PM, Paul Rubin wrote:
> I'd personally prefer
>
> if not bool(myValue):
>
> which would call the myValue's __bool__ method if it chose to implement
> one. Explicit is better than implicit.
That's just ugly. Probably a more explicit way would be to have an
is_true() and is_false() function/method. if is_false(my_value).
But that's ugly too, especially when the idea of emptiness or falseness
is so consistently defined across python types. I have yet to encounter
any situation where I got tripped up on such a small thing as the OP.
More information about the Python-list
mailing list