People coming from C, C++ or Perl might miss the so-called ternary operator ?: (condition ? then-expr : else-expr). It's most often used for avoiding several lines of code and temporary variables for very simple decisions, like printing the plural form of words after a counter (see example code).
There are two ways to get the same effect in Python: selecting one of two values from a tuple, or using the special behaviour of the "and" and "or" operators in Python. The second method has the advantage that only ONE of the two possible expressions is evaluated, and is thus more close to the behaviour of ?: as defined by C.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
# explicit if for i in range(1,3): if i == 1: plural = '' else: plural = 's' print "The loop ran %d time%s" % (i, plural) # selecting from tuple for i in range(1,3): print "The loop ran %d time%s" % (i, ('','s')[i != 1]) # short-circuited logical expression for i in range(1,3): print "The loop ran %d time%s" % (i, i != 1 and 's' or '') # Output of all loops: # The loop ran 1 time # The loop ran 2 times