PEP308: Yet another syntax proposal
iko at cd.chalmers.se
Tue Feb 11 16:19:48 CET 2003
In article <3E4850DB.DE1C224B at alcyone.com>,
Erik Max Francis <max at alcyone.com> wrote:
>Indeed. There are _always_ alternatives, everybody knows that. The
>issue is not whether or not there is an expression that fundamentally
>cannot be written without the conditional operator, because everybody on
>both sides of the debate knows very well that there is no such thing.
Of course, the conditional is essentially just an abbreviated
if-statement with assignment. I doubt anyone is arguing against
it purely based on the fact that it implements functionality that
is already present. If that was a problem, why do we have
file.readlines() when you could just as well do file.read().split()?
>That's not the question. The question is whether or not some forms are
>more readable with the conditional operator than without it.
Exactly, and if so, whether those cases are frequent and ugly
enough that it warrants new syntax (that will undoubtedly be
abused for purposes where it will make code less readable).
Let's not forget that one of the strengths of python is that
it is easy to read and understand other peoples code, and I
believe at least part of the reason for that is that there
are few constructs in python that encourage abuse. (Cue
someone to reply with a list of two dozen abused constructs.)
>fundamentally frustrating when people shoot down legitimate examples of
>the conditional operator with, "Oh, but you could have done it _this_
>way." Well, of _course_ you could have. The question is whether the
>conditional form is useful and readable on its own merits.
No, it's not whether it's useful or not on it's own merits alone.
If it were, you could easily argue that every possible construct
under the sun has a use, and therefore python should support them
all. Even perl's implicit variable assignment has some use (as
people do use it), but you're not arguing that something like that
should be added to python are you?
>When people shoot down the max example (e.g., if x > y: x else: y) with
>"Well, you should have used max(x, y)!" is utterly frustrating.
No, this is exactly the point. There's no need for the conditional
in this case because we have max() and that is more readable.
-- Of course I'm crazy, but that doesn't mean I'm wrong.
Anders Hammarquist | iko at cd.chalmers.se
Physics student, Chalmers University of Technology, | Hem: +46 31 88 48 50
G|teborg, Sweden. RADIO: SM6XMM and N2JGL | Mob: +46 707 27 86 87
More information about the Python-list