Attitude about new keywords

Peter Hansen peter at engcorp.com
Tue Feb 11 11:29:11 EST 2003


Martin Maney wrote:
> 
> 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?  

I never found the indentation in Python to be a problem when writing.
In fact, as I recall I was (after a moment of surprise) very agreeable 
with the feeling it gave, from the start.  It just made sense, and
gave an immediate payback in readability.

But *writing* Python is in no way what this issue is about, except
from the point of view of avoiding common bugs.  Readability is
the real concern (for this one aspect at least), and the reversal
reduces readability inherently, I would argue.  If not inherently,
then at least for me personally it's a real problem, and likely to
be a source of problems when maintaining code.

I considered trying to write some sample cases just to get a feel
for it, as you did, but I decided not to bother because in no
case where I *read* that form did I find it readable, even after
seeing dozens of posts with examples.

-Peter




More information about the Python-list mailing list