PEP 308: Yet another syntax proposal.

John Roth johnroth at
Sat Feb 15 14:20:25 CET 2003

<sismex01 at> wrote in message
news:mailman.1045248651.18737.python-list at
> Following the discussion (and tossing another log
> into the flame), what do y'all think of this? It's
> modelled after lambda:, of course, but it's a short-
> circuiting expression:
> result = when <condition> : <trueval> else <falseval>
> The idea being that it's already a known form,
> except that instead of being lambda, it's "when".
> <trueval> and <falseval> are expressions, and as
> such, they can be also "when"-expressions, so it's
> linkable, for those perverts who like to do such
> things as:

IMO, the plus side is that there's a keyword introducing
the construct.

The minus side is the mixture of keywords and
special characters. It should be one or the other.

And, of course, an "elif" should be in there as well.

There's also an ambiguity with the final <expression>.
Where does it end? Consider:

x = when a == b: c + 1 else d + 2

if the true value fires, is the result c + 1 or c + 1 + 2?

John Roth

More information about the Python-list mailing list