On 11 Feb 2007 16:57:07 -0800, Carl Banks <[EMAIL PROTECTED]> wrote: > You don't need any ternary operator to avoid repetition, anyways. You > could factor the common parts out like this: > > if n == 1: > what = "a car" > else: > what = "%d cars" % n > print "I saw %s" % what
Or even better (IMHO): what = "%d cars" % n if n == 1: what = "a car" print "I saw %s" % what One less line and just as readable. > but what's the point? It's just a few repeated characters two lines > apart. Peter's version is the most easily read version here, > including the one using the official ternary operator. Agreed. -- mvh Björn -- http://mail.python.org/mailman/listinfo/python-list