Conditionals

if-else

     # Compute maximum (z) of a and b
     if a < b:
        z = b
     else:
        z = a

The pass statement

     if a < b:
        pass       # Do nothing
     else:
        z = a

Notes:

  • Indentation used to denote bodies.
  • pass used to denote an empty body.
  • There is no '?:' operator.
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 8
July 17, 2000, beazley@cs.uchicago.edu
>>>