Proposed PEP for a Conditional Expression

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


"Alex Martelli" <aleax at aleax.it> wrote in message news:<9nidrm01j7q at enews1.newsguy.com>...
> 
> 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.

Paul



More information about the Python-list mailing list