PEP 308: Pep Update

Paul Simmonds psimmo60 at hotmail.com
Thu Feb 27 09:30:09 EST 2003


"Norman Petry" <npetry1 at canada.com> wrote in message news:<pan.2003.02.27.06.06.21.230621 at canada.com>...
<snipped>
> I think that the C syntax for the ternary is very poor, mostly because
> there is nothing intuitively obvious about it.
<snipped> 
> 1) it uses symbols, rather than keywords, which are meaningless unless the
> reader is already familiar with the construct from another programming
> language (since they have no obvious analogue in mathematics or some
> natural language).  This makes it an especially poor choice for Python,
> which has important applications as a teaching (i.e. first) language.
> 2) it is arbitrary, in that nothing about the syntax would suggest that
> the trueValue should precede the colon (i.e. C? falseValue : trueValue is
> equally logical, since a more natural order might be False(0) : True(1)).
<snipped> 
> 3) it is confusing, since using the colon to separate alternatives would
> conflict with the established meaning of that symbol in Python.  In
< heavily snipped>
> To me, 'x if C else y' looks perfectly natural (I don't often code in C),
> and has the elegance that I expect in the design of Python.
<snipped>
My first post in this debate, as I figured I'd wait and see where the
lines were. I think there's a silent group of people who would agree
with most if not all the points mentioned. The ones above are just the
ones I agree with most.

I do program in C, although I avoid it whenever possible now that I
have Python, as things like multi-line ternary operators make my eyes
bleed.

Good post Norman.

TernaryOperator = "x if C else y" if CommunityAgrees else None

Thanks,
Paul




More information about the Python-list mailing list