order of test

Erik Max Francis max at alcyone.com
Mon Jul 29 04:32:09 EDT 2002


William Dode wrote:

> can we be sure of the order of a test expression ?
> i mean that
> t=["one","two"]
> x=10
> if x<2 and t[x]=="oups":
> 
> will never throw an exception if t[2] will be tested before x<2

Yes.  In Python, the and, or operators are short-circuiting.

-- 
 Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
 __ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/  \ See the son in your bad day / Smell the flowers in the valley
\__/ Chante Moore
    Bosskey.net: Aliens vs. Predator 2 / http://www.bosskey.net/avp2/
 A personal guide to Aliens vs. Predator 2.



More information about the Python-list mailing list