compound conditional statements

Jeff Epler jepler at unpythonic.net
Mon Sep 15 17:51:00 EDT 2003


On Mon, Sep 15, 2003 at 02:31:06PM -0700, beliavsky at aol.com wrote:
> If I have code 
> 
> if (aa or bb): print "true", 
> 
> does Python evaluate aa and bb in any particular order? Can I assume that if 
> aa is true, bb will not be evaluated?

Yes.

For more information, read the language reference:
http://python.org/doc/ref/Booleans.html
    The expression x or y first evaluates x; if x is true, its value is
    returned; otherwise, y is evaluated and the resulting value is
    returned.  

Jeff





More information about the Python-list mailing list