Proposed PEP for a Conditional Expression
Terry Reedy
tjreedy at home.com
Mon Sep 10 09:10:37 EDT 2001
"Christian Tanzer" <tanzer at swing.co.at> wrote in message
news:mailman.1000105331.31775.python-list at python.org...
>Conditional expressions provide some nice benefits totally unrelated
to lambdas.
> One example: with a trivial class, one can put expressions into
format
> directives, like
> "Found %(number)d error%(if number == 1 : '' else : 's')s" %
trivial
Python does not evaluate expressions inside strings and I do not
expect it ever will.
However, this can be rewritten today as
"Found %(number)d error%s" % (num, num != 1 and 's' or '')
Terry J. Reedy
More information about the Python-list
mailing list