PEP 308: Pep Update

Lulu of the Lotus-Eaters mertz at gnosis.cx
Thu Feb 27 02:17:34 EST 2003


While I agree with most of Petry's comments, he misses something
important.

"Norman Petry" <npetry1 at canada.com> wrote previously:
|The objections to the 'x if C else y' syntax have all been very weak,
|imho.  Most people who have criticised the proposal have done little more
|than to point out that the condition appears in the middle of the
|expression (unlike C, which presumably does things the "right" way).

My objection isn't that the order is "unlike C".  My objection is that
it is UNLIKE PYTHON.

In every Python construct that exists now, a condition is stated BEFORE
the actions that depend on it.  These are so familiar that Petry may
have forgotten them:

    if C:
        var = x
    else:
        var = y

There's extra in there (and it's a statement block rather than an
expression).  But seeing the condition first is what's natural.
Likewise, a 'for' or 'while' loop has its "condition" first.  And even a
'try/except' statement is similar here.

The pattern "evaluate a criteria, THEN take action" is quite uniform in
Python.  The ternary form "x if C else y" breaks this uniformity.

Yours, Lulu...

--
 mertz@  _/_/_/_/ THIS MESSAGE WAS BROUGHT TO YOU BY: \_\_\_\_    n o
gnosis  _/_/             Postmodern Enterprises            \_\_
.cx    _/_/                                                 \_\_  d o
      _/_/_/ IN A WORLD W/O WALLS, THERE WOULD BE NO GATES \_\_\_ z e






More information about the Python-list mailing list