[Python-Dev] Adding C ternary select (a?b:c) to Python?

gvwilson@nevex.com gvwilson@nevex.com
Mon, 31 Jan 2000 12:44:53 -0500 (EST)


> It (?:) would allow you to incorporate logic into expressions. 
> There are contexts where only expressions are allowed, such as:
>   - lambdas
>   - DTML expr attributes
> in which I'd very much like to incorporate tests.

Don't know much about DTML, but believe that being able to put
conditionals in lambdas would make the latter much more useful.

> > The ?: syntax
> > does not introduce any new "functionality" to the language,
> Yes it does.

Is anything possible with ?: that's impossible without? No --- Python is
Turing-equivalent before and after the change.

Is anything easier with ?: --- yes.

Does this make up for the added complexity?  Dunno (see below).

> > The second qustion I'd ask is, who is this aimed at?  It's certainly not
> > aimed at first-time programmers, as I know from experience that the ?:
> > is one of the hardest things to teach people in C (after pointers),
> Hm. I can't agree.

Strongly agree with the first author --- IME, ?: is very hard to teach.

Greg