(no) fast boolean evaluation ?

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Fri Aug 3 16:24:24 CEST 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:
    if another_condition:

But that's specific to the syntax of the language. You could, if you
choose, design a language where elif was unnecessary:

if condition:
else if another_condition:

What advantage is there to "elif", apart from it needing three fewer
characters to type?


More information about the Python-list mailing list