Proposed PEP for a Conditional Expression

Paul Boddie paul at
Thu Sep 13 11:46:56 CEST 2001

"Alex Martelli" <aleax at> wrote in message news:<9nidrm01j7q at>...
> Seconded on both scores.  Specifically, adding to Python all the
> features that "lots of people" ask for would ensure Python's
> transformation into a huge, bloated language. *THIS* is "what's
> wrong with just satisfying people", as here rhetorically asked:
> trying to make everybody happy will ensure nobody's happy:-).

Interestingly, whilst I have made use of the ... ? ... : ... construct
in the C family of languages and Java, I rarely want to use it (and
thus rarely miss it) in Python. Most frequently, when I do use it in
the former languages, it is to deal with situations like this:

  String outputString = (otherString == null) ? "" : otherString;

In Python, one can use the following instead in this case:

  outputString = otherString or ""

Personally, I find complicated uses of ?: difficult to scan and
understand rapidly, contrary to spurious arguments about its supposed
similarity to English language constructs.


More information about the Python-list mailing list