Attitude about new keywords
Evan
evan at 4-am.com
Mon Feb 10 21:52:07 EST 2003
Erik Max Francis wrote:
> The require-parentheses argument leads to weird cases such as that of a
> function call:
>
> f(x if C else y)
>
> would be illegal, instead it would have to be written
>
> f((x if C else y))
I may well be in the minority, here, but I see this as a benefit. As
long as attempts at using the first form are met with a SyntaxError that
tells you exactly what you need to do, the only cost is having to type
two more characters. Sooner or later, though, 'f' is going to grow
another parameter, and then it's:
f(if C: x else: y, z) vs. f((if C: x else: y), z)
Also, consider the one-tuple:
(if C: x else: y,) vs. ((if C: x else: y),)
Yes, precedence rules can be set up so that it will almost always do the
"right thing", but with mandatory parens readability is guaranteed. I
consider that a considerable advantage for a construct whose very
(potential) existence is despised by so many Pythonians.
Cheers,
Evan @ 4-am
More information about the Python-list
mailing list