Attitude about new keywords

Martin Maney maney at pobox.com
Mon Feb 10 22:57:25 EST 2003


Peter Hansen <peter at engcorp.com> wrote:
> In the case of the ternary expression, however, the condition
> is *the* key item.  Putting the true result first, *then*
> the condition, and then the false result, is just plain backwards.
> No different than the "do all this long stuff if test" syntax
> from Perl.

Y'know, I had expected to dislike the PEP's form, and for exactly that
reason - I absolutely loathe Perl's ass-backwards guard formation. 
However, when I sat down with a modest sample of candidates and
actually tried writing them in that form...

  x = the_usual_thing if nothing_odd else uh_oh_its_parrots_again

Y'know how, before you try ever writing Python, the indentation *is*
structure thing seems a little dicey?  Okay, this wasn't (or hasn't yet
been) that much of a reversal, but it does seem to work well enough
that I believe I could quite happily live with it.  I really don't know
how heavily I'd be using it; approximately 0% for the next year or more
seems a pretty safe prediction, give it wouldn't arrive until 2.4  :-)

> Just because the test in the list comprehension comes later is
> no reason to insist that it must come later in other cases.  

And that's another thing.  I've seen, as it happens, a couple of
mentions of this during this evening's reading, and they all seem to
miss the point.  The if *has* to be there because it is a modifier
that's part of the "in this_here_sequence_thing" clause.  It helps
define the sequence which the action part acts upon, so where else
*could* it go?

Sorry, I'm sure this has been said already, but I don't recall ever
having seen it explained in quite this way, so I wanted to see if it
still made sense when I tried to write it down.  :-)

I'm developing a healthy respect for Guido's knack for cramming a huge
mass of implications into very small seeming features - not that I
didn't have a good bit already.  And they natter about "poetic" Perl! 
LOL!




More information about the Python-list mailing list