conditional expressions

Pedro RODRIGUEZ pedro_rodriguez at club-internet.fr
Fri Sep 27 05:30:22 EDT 2002


On Fri, 27 Sep 2002 09:47:09 +0200, Alex Martelli wrote:

> Pedro RODRIGUEZ wrote:
>         ...
>> The first one isn't possible in a Python expression AFAIK,
> 
> Of course it is -- you seem to keep ignoring the semantics of Python's
> "and" and "or" operators, which ARE short-circuiting (and return one of
> the operands, differently from C/C++'s short-circuiting && and ||, which
> return 0 or 1 whatever operands they're given).
> 

>From now on, I will know them :/ (even read ref manual on boolean
operations as a punition ;)

Always thought an expression was completely evaluated prior computation,
like in Ada - execept for and then/or else, I was wrong.

>>> def a(): print 1
...
>>> def b(): print 2
...
>>> def c(): print 3
...
>>> if a() and b() and c(): pass
...
1
>>>


Sorry for the noise

Pedro



More information about the Python-list mailing list