[Python-Dev] Adding a conditional expression in Py3.0 (original) (raw)

Terry Reedy tjreedy at udel.edu
Sat Sep 24 03:48:39 CEST 2005


Need I continue? Or is the dead still dead?

Since 'a if b else c' is not obviously dead, I will summarize my argument against it thusly:

It is ambiguous to people because it is can be parsed (by people, who are not automatons) as either '(a if) b (else c)' or 'a (if b) (else c)'. The first parsing, seeing a as the conditional rather than the consequent, as in the the second, is at least as reasonable as the second given precedents in both other algorithm languages and natural languages (in English, at least, but I suspect others also).

Ambiguity sometimes leads to discomfort. As important, it sometimes leads to bugs either in writing or reading. The impetus for this discussion was a real-life buggy example of the and/or construct. Its replacement should be something not similarly bug-prone, even if for a different reason.

Terry J. Reedy



More information about the Python-Dev mailing list