Proposed PEP for a Conditional Expression
tjreedy at home.com
Mon Sep 10 15:10:37 CEST 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
> One example: with a trivial class, one can put expressions into
> directives, like
> "Found %(number)d error%(if number == 1 : '' else : 's')s" %
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