(no) fast boolean evaluation ?
Steven D'Aprano
steve at REMOVE.THIS.cybersource.com.au
Fri Aug 3 10:24:24 EDT 2007
On Fri, 03 Aug 2007 10:20:59 +0200, Bruno Desthuilliers wrote:
> Joshua J. Kugler a écrit :
>> On Thursday 02 August 2007 15:19, Evan Klitzke wrote:
>>>> I discovered that boolean evaluation in Python is done "fast"
>>>> (as soon as the condition is ok, the rest of the expression is ignored).
>>> This is standard behavior in every language I've ever encountered.
>>
>> Then you've never programmed in VB (at least 6, don't know if .net still
>> does this). Nested IF statements. AAAAAAAAAAAAAAAAAAAACK!
>
> I do remember an even brain-deadiest language that not only didn't
> short-circuit boolean operators but also didn't have an "elif" statement...
Is it a secret?
I'm a little perplexed at why you say a language without "elif" is a good
sign of brain-death in a programming language. I understand that, given
the parsing rules of Python, it is better to use elif than the equivalent:
if condition:
pass
else:
if another_condition:
pass
But that's specific to the syntax of the language. You could, if you
choose, design a language where elif was unnecessary:
if condition:
pass
else if another_condition:
pass
What advantage is there to "elif", apart from it needing three fewer
characters to type?
--
Steven.
More information about the Python-list
mailing list