PEP 308: I liked the original proposal better

Sean Ross sross at connectmail.carleton.ca
Fri Feb 14 13:35:56 EST 2003


+1 for the original propasal.

1.  <expression> if <condition> else <expression>

Personally, I do not find it confusing at all and I have not seen another
alternative that I've found as elegant as the original.
The only other alternatives I've liked so far have been, (in order of
preference):

    # which has been rejected, for adding a keyword
2.    <expression> when <condition> else <expression>,


    # with or without brackets, this is verbose either way and adds a
keyword
3a.    if <condition> then <expression> else <expression>,


3b.    <condition> then <expression> else <expression>       # which also
adds a keyword
    """
    with C. Tismers added utility of
        <condition> then <expression>
        <expression> else <expression>
    which I am ambivilant towards...I often like the idea, and I'm often
leary of it
    kind of like I'm often attracted by ruby, but soon repulsed...
   "end statements,  for crying out loud, and oh so many other @things"
    """

    and


I don't much care for

4.   if <condition>: <expression> else: <expression>   # with or without
brackets

for the simple reason that it looks too much like an if statement. I realize
that others deem this
benificial, and I understand and agree with their reasoning, however I
dislike the idea of having
a statement and an expression sharing identical or near identical syntax
despite their sharing
identical or near identical semantics.

But, primarily, when I see colons in Python I /generally/ think "what
follows is a suite" and
"a suite is an indented block of code". I like this association very much.

( so much so that I'd like to see lambda replaced by something like
        anonymous = do(*args, **kwds):
                                    suite
and
        m = { key1: val1, key2:val2}
with
       m = { key1=val1, key2=val2}

sad,  really,  I know,  but I digress...
)

Anyway, I don't find 4. difficult to follow,  I simply find that it clashes
with
my mental model of the language ( "colons /usually/ mean blocks" ) and I
find it less attractive
then the other alternatives proposed(excessive punctuation).
(Although I do keep wavering on 3b...)

To sum up, I like 1. best (actually, 2. best, but it won't happen, so I'll
favor what could happen)
And the rest, I don't care for much at all, but if they're to be chosen
from, my preferences are as
numbered (except for that darn 3b...I can't decide whether I like that one
or not).

That being said,  I look forward to the vote, whatever form it might take.
Sean






More information about the Python-list mailing list