Re: (no) fast boolean evaluation ?

2007-08-06 Thread Bruno Desthuilliers
Ed Leafe a écrit : On Aug 3, 2007, at 11:57 AM, Bruno Desthuilliers wrote: Sorry, I forgot to mention the language did not allow to have else if in the same statement. IOW : if some_condition then do_sometehing else if some_other_condition then do_something_else else

Re: (no) fast boolean evaluation ? missing NOT

2007-08-05 Thread Gabriel Genellina
En Fri, 03 Aug 2007 11:56:07 -0300, Roel Schroeven [EMAIL PROTECTED] escribió: Paul Boddie schreef: On 3 Aug, 11:45, Stef Mientki [EMAIL PROTECTED] wrote: Sorry, my question missed the essential NOT, here is an example, that behaves different in Delphi, (so I guess Delphi is not a real

Re: (no) fast boolean evaluation ?

2007-08-05 Thread Paddy
On Aug 4, 5:33 pm, Paddy [EMAIL PROTECTED] wrote: On Aug 4, 4:18 pm, Paddy [EMAIL PROTECTED] wrote: On Aug 2, 10:47 pm, Stef Mientki [EMAIL PROTECTED] wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the

Re: (no) fast boolean evaluation ?

2007-08-04 Thread Paddy
On Aug 2, 10:47 pm, Stef Mientki [EMAIL PROTECTED] wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler switch to turn it on/off ? thanks, Stef

Re: (no) fast boolean evaluation ?

2007-08-04 Thread Paddy
On Aug 4, 4:18 pm, Paddy [EMAIL PROTECTED] wrote: On Aug 2, 10:47 pm, Stef Mientki [EMAIL PROTECTED] wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there

Re: (no) fast boolean evaluation ?

2007-08-03 Thread Laurent Pointal
Stef Mientki a écrit : hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler switch to turn it on/off ? As it was replied, its standard behavior and

Re: (no) fast boolean evaluation ? missing NOT

2007-08-03 Thread Laurent Pointal
Stef Mientki a écrit : Python def Some_Function (const): print 'Ive been here', const return True A = True if A and Some_Function (4 ): print 'I knew it was True' else: print 'I''ll never print this' /Python Output Ive been here 4 I knew it was True /Output I

Re: (no) fast boolean evaluation ? missing NOT

2007-08-03 Thread Stef Mientki
John Machin wrote: On Aug 3, 8:55 am, Ian Clark [EMAIL PROTECTED] wrote: Stef Mientki wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler switch to

Re: (no) fast boolean evaluation ? missing NOT

2007-08-03 Thread Bruno Desthuilliers
Stef Mientki a écrit : (snip) Gabriel: you pointed me to this page: The exact behavior is defined in the Language Reference http://docs.python.org/ref/Booleans.html quote or_test ::= and_test | or_test or and_test /quote Can you imagine, while I'm not a programmer, just a

Re: (no) fast boolean evaluation ? missing NOT

2007-08-03 Thread Roel Schroeven
Paul Boddie schreef: On 3 Aug, 11:45, Stef Mientki [EMAIL PROTECTED] wrote: Sorry, my question missed the essential NOT, here is an example, that behaves different in Delphi, (so I guess Delphi is not a real language ;-) Delphi is based on Pascal, and from what I can recall from my

Re: (no) fast boolean evaluation ? missing NOT

2007-08-03 Thread Paul Boddie
On 3 Aug, 11:45, Stef Mientki [EMAIL PROTECTED] wrote: Sorry, my question missed the essential NOT, here is an example, that behaves different in Delphi, (so I guess Delphi is not a real language ;-) Delphi is based on Pascal, and from what I can recall from my university textbook, there

Re: (no) fast boolean evaluation ?

2007-08-03 Thread Bruno Desthuilliers
Steven D'Aprano a écrit : 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

Re: (no) fast boolean evaluation ?

2007-08-03 Thread Bruno Desthuilliers
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

Re: (no) fast boolean evaluation ?

2007-08-03 Thread Neil Cerutti
On 2007-08-03, Steven D'Aprano [EMAIL PROTECTED] wrote: 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

Re: (no) fast boolean evaluation ? missing NOT

2007-08-03 Thread Stef Mientki
Laurent Pointal wrote: Stef Mientki a écrit : Python def Some_Function (const): print 'Ive been here', const return True A = True if A and Some_Function (4 ): print 'I knew it was True' else: print 'I''ll never print this' /Python Output Ive been here 4 I knew it

Re: (no) fast boolean evaluation ? missing NOT

2007-08-03 Thread Diez B. Roggisch
Stef Mientki schrieb: John Machin wrote: On Aug 3, 8:55 am, Ian Clark [EMAIL PROTECTED] wrote: Stef Mientki wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is

Re: (no) fast boolean evaluation ?

2007-08-03 Thread Ed Leafe
On Aug 3, 2007, at 11:57 AM, Bruno Desthuilliers wrote: Sorry, I forgot to mention the language did not allow to have else if in the same statement. IOW : if some_condition then do_sometehing else if some_other_condition then do_something_else else if

Re: (no) fast boolean evaluation ?

2007-08-03 Thread Steven D'Aprano
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

Re: (no) fast boolean evaluation ?

2007-08-03 Thread Irmen de Jong
John Machin wrote: (you_are_confused and/or function_returns_bool_but_has__side_effects()) That above expression should be written more explicitly like: function_result = function_returning_bool_but_with_side_effects() if you_are_confused or function_result: do_something_nice()

Re: (no) fast boolean evaluation ?

2007-08-03 Thread Neil Cerutti
On 2007-08-03, Ed Leafe [EMAIL PROTECTED] wrote: On Aug 3, 2007, at 11:57 AM, Bruno Desthuilliers wrote: Sorry, I forgot to mention the language did not allow to have else if in the same statement. IOW : if some_condition then do_sometehing else if some_other_condition then

Re: (no) fast boolean evaluation ? missing NOT

2007-08-03 Thread Terry Reedy
Stef Mientki [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] | John Machin wrote: | So now I'm left with just one question: | for bitwise operations I should use , |, ^ | for boolean operations I should use and, or, xor | but after doing some test I find strange effects: | A = 4 | B

Re: (no) fast boolean evaluation ?

2007-08-03 Thread Frank Swarbrick
Ian Clark wrote: Stef Mientki wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler switch to turn it on/off ? It's called short circuit

(no) fast boolean evaluation ?

2007-08-02 Thread Stef Mientki
hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler switch to turn it on/off ? thanks, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list

Re: (no) fast boolean evaluation ?

2007-08-02 Thread Evan Klitzke
On 8/2/07, Stef Mientki [EMAIL PROTECTED] wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler switch to turn it on/off ? This is standard behavior

Re: (no) fast boolean evaluation ?

2007-08-02 Thread Ian Clark
Stef Mientki wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler switch to turn it on/off ? thanks, Stef Mientki It's called short circuit

Re: (no) fast boolean evaluation ?

2007-08-02 Thread Gabriel Genellina
En Thu, 02 Aug 2007 18:47:49 -0300, Stef Mientki [EMAIL PROTECTED] escribió: I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler switch to turn it on/off ?

Re: (no) fast boolean evaluation ?

2007-08-02 Thread John Machin
On Aug 3, 8:55 am, Ian Clark [EMAIL PROTECTED] wrote: Stef Mientki wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler switch to turn it on/off

Re: (no) fast boolean evaluation ?

2007-08-02 Thread John Machin
On Aug 3, 9:19 am, Evan Klitzke [EMAIL PROTECTED] wrote: On 8/2/07, Stef Mientki [EMAIL PROTECTED] wrote: hello, I discovered that boolean evaluation in Python is done fast (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a

Re: (no) fast boolean evaluation ?

2007-08-02 Thread Joshua J. Kugler
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