On Feb 25, 9:18 pm, Karlo Lozovina <[EMAIL PROTECTED]> wrote:
> Hi all! Here is what's bugging me: let's say I have this code:
>
> if (<condition1>) and (<condition2>) and (<condition3>):
>   do_something()
>
> Is there a guarantee that Python will evaluate those conditions in order (1,
> 2, 3)? I know I can write that as a nested if, and avoid the problem
> altogether, but now I'm curious about this ;).

Did you try to find the answer to your question in the python
reference manual? The relevant page is http://docs.python.org/ref/Booleans.html

To quote it:
The expression 'x and y' first evaluates x; if x is false, its value
is returned; otherwise, y is evaluated and the resulting value is
returned.

--
Paul Hankin

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to