condition and True or False
Carl Banks
pavlovevidence at gmail.com
Sun May 2 17:49:16 EDT 2010
On May 2, 10:14 am, Paul McGuire <pt... at austin.rr.com> wrote:
> While sifting through some code looking for old "x and y or z" code
> that might better be coded using "y if x else z", I came across this
> puzzler:
>
> x = <boolean expression> and True or False
>
> What is "and True or False" adding to this picture? The boolean
> expression part is already evaluating to a boolean, so I don't
> understand why a code author would feel compelled to beat this one
> over the head with the additional "and True or False".
>
> I did a little code Googling and found a few other Python instances of
> this, but also many Lua instances. I'm not that familiar with Lua, is
> this a practice that one who uses Lua frequently might carry over to
> Python, not realizing that the added "and True or False" is redundant?
>
> Other theories?
The person who wrote it was a programmer who fancied himself to be
more clever than he really was.
Convenient though they may be, people always abuse (and often misuse)
these boolean shortcuts, a big reason why I don't like them. You
never see crap like this in Java.
Carl Banks
More information about the Python-list
mailing list