PEP 308: some candidate uses cases from live code

Andrew Koenig ark at
Mon Feb 10 23:40:44 CET 2003

Steve> However, it clearly introduces new precedence problems into the
Steve> syntax: how do I know you meant

Steve>"Ran %d test%s in %.3fs" %
Steve>                        (run, (if run==1: "" else: "s"), timeTaken)

Steve> and not (apart from the run-time error it would produce)

Steve>"Ran %d test%s in %.3fs" %
Steve>                        (run, if run==1: "" else: ("s", timeTaken))

Steve> Methinks anything that allows colons inside expressions will be
Steve> tough for us to read.

I'm not introducing any new precedence problems.

You know which of the alternatives above I mean in the same way you know that

        foo(lambda x, y: x, y)


        foo((lambda x, y: x), y)

and not

        foo(lambda x, y: (x, y))

You can like or dislike the existing rules for colons inside expressions,
but I'm not proposing to change them.

Andrew Koenig, ark at,

More information about the Python-list mailing list