[Python-Dev] Adding a conditional expression in Py3.0

Gareth McCaughan gmccaughan at synaptics-uk.com
Mon Sep 26 12:14:09 CEST 2005


On Saturday 2005-09-24 04:21, Terry Reedy wrote:

> Never wrote a single line, and may have not read one (in DDJ? Byte?) for 
> 15-20 years.  How do *you* read such C?  Cond 'Qmark' ....?

I seldom have to read C code aloud, and the ?: operator is
rare-ish; but I would suggest reading a?b:c as "a chooses b else c"
or (shaving a syllable) "a gives b else c" or something like that.
Or, ploddingly but unambiguously, "a query b colon c".

> Now, can you honestly say that you would (naively) read
> 
>   return foo if bar else baz
> 
> and be certain you knew what it meant?

I can't imagine *actually* reading it as if "foo" were the
condition. But I can imagine reading it, to begin with, as if
it were a Perlish conditionalized statement: "(return foo) if
bar else ... aw heck, that can't be right". Which is probably
benign but slows down comprehension.

-- 
g



More information about the Python-Dev mailing list