Yet Another PEP308 syntax
gerrit at nl.linux.org
Tue Feb 11 17:52:48 CET 2003
David Eppstein schreef op maandag 10 februari om 17:27:03 +0000:
> In article <mailman.1044892786.2769.python-list at python.org>,
> Gerrit Holl <gerrit at nl.linux.org> wrote:
> > although I am against a ternary operator, here is Yet Another PEP308
> > syntax:
> > a = ?(test, true_case, false_case)
> > or
> > a = test?(true_case, false_case)
> Why do people keep proposing cryptic punctuation-based syntax for this?
> Using punctuation instead of words makes the meaning non-obvious,
> especially to new programmers who have not used C/C++/Java
I disagree. In my opinion, a '?' after a test can be very obvious, almost
as obvious as an 'if' before a test. But a 'if' before a test can mean
either that it is a statement, or that the expression doesn't read from
left to right. An 'if' after a test is not logic, but a '?' after a test
Regarding 'new programmers', I do not know any language apart from
Python, which is not only a weakness, but also a strenght: I know what's
its like to learn to program with Python, and I am not being distracted
by thoughts like "Oh, this is Perl/C/Java".
> and so it
> seems unlikely that the BDFL will ever accept it. Such proposals
> clutter the discussion without making progress towards getting a ternary
> included in the language.
I disagree, but I am against a ternary included in the language so I won't
be unhappy about it <w>. It's just that _if_ a ternary is included, I'd
personally prefer '?'-like punctuation to using 'if-else' keywords.
But I am not happy about the ','. Maybe:
 test?(true_case or false_case)
 test?(true_case else false_case)
But than is the disadvantage of the 'of' keyword which can mean something
different. The disadvantage of
 test?(true_case || false_case)
is that the '||' is very random (I only know it from Bash).
For my own proposals, my order of preferation is:
, , , , .
But then, I don't even _want_ a ternary operator ;)
Asperger Syndroom - een persoonlijke benadering:
Het zijn tijden om je zelf met politiek te bemoeien:
More information about the Python-list