[Python-Dev] Adding C ternary select (a?b:c) to Python?
Ken Manheimer
klm@digicool.com
Mon, 31 Jan 2000 12:58:07 -0500 (EST)
On Mon, 31 Jan 2000, Fred L. Drake, Jr. wrote:
> Ka-Ping Yee writes:
> > a scan through a decent chunk of Python would be useful to find out how
> > often this construct (in its "and"/"or" incarnation) actually gets used.
>
> I'm not sure what the survey provides other than a lower bound. I
> think most Python programmers who want the ?: functionality avoid the
> and/or approach because of the ugliness. I know I do.
Good point. Just because the workaround is bad doesn't mean the thing
being worked-around is unimportant...
I should weigh in to say that i have really really wanted, in particular,
the ability to have a condition on the right hand side of an assignement.
IIR, on some occasions it seemed less clear to have to use separate
statements for what was essentially a single assignment that just, eg,
differed by a single term. I wanted (want) some reasonable way to express
the condition in an expression. I can see how this compactness could lead
to regex-style convolution of expressions, but that could be avoided by
providing a not-too-terse syntax.
(I should admit that may have succumbed to the (a and (b,) or (c,))[0]
grotesquerie at some point! Not sure. Wish i could recall what might
have justified succumbing - the mere fact that i may have, without
compelling justification, might-should disqualify my judgement on the
matter, ay? Hey, maybe i didn't, i was just imagining it - now am i not a
sterling judge?-)
Ken
klm@digicool.com