PEP 308: ternary operator

Sheila King usenet at thinkspot.net
Fri Feb 21 16:07:12 EST 2003


On Fri, 21 Feb 2003 13:09:17 -0500, Peter Hansen <peter at engcorp.com> wrote
in comp.lang.python in article <3E566B4D.765A7569 at engcorp.com>:

> sismex01 at hebmex.com wrote:
> > 
> > OTOH, there's something to be said about helping to keep
> > our favorite coding language/environment pollution-free,
> > while helping evolve.
> > 
> > Dont'cha think?
> 
> I have to agree.  So far, very few (perhaps none... I'm still thinking
> about it) of the proposals "feel like Python" to me.  In fact, I'm 
> tempted to say only Guido's original feels like Python, and I think I'm
> sitting on the fence between voting "no to any change" and "yes only
> to the original" in spite of my concern about the order of operands
> in the original.
> 
> I like your reminder about Python being "executable pseudocode".  The
> original and *maybe* one of the new alternatives feel like that still.
> The C-style ternary simply does not.
> 
> Actually, "(true-expr) when (cond-expr) else (false-expr)" is perhaps
> my favourite over even the original, which I think bothers me more 
> with its "if" in the middle.  I'm inclined to think at least some small
> bit of code uses "when" as a keyword, mind you...  :-(

Hear, hear.

I really prefer wordy, psuedo-code like constructions, that feel, at least
to me, more like Python.

Regardless of how many Python programmers are familiar with C-like syntax.

I also prefer the construct

(true-expr) when (cond-expr) else (false-expr)

over all else that has been suggested, although the original suggestion by
Guido is also acceptable. Words preferable to punctuation characters in all
instances.

Haven't had much time to read the voluminous amounts of discussion on this
issue.



-- 
Sheila King
http://www.thinkspot.net/sheila/
http://www.k12groups.org/




More information about the Python-list mailing list