Conditional Expressions don't solve the problem

Steve Holden sholden at holdenweb.com
Thu Oct 18 20:29:58 EDT 2001


"Carl Banks" <idot at vt.edu> wrote ...
> Paul Rubin <phr-n2001d at nightsong.com> wrote:
> >
> > But it's not just saving keystrokes--the usual place for an assigment
> > in an expression is in the control expression for a while loop.
> > Having to split it into several statements clutters up the code and
> > makes the readability WORSE by moving the test condition away from the
> > 'while' keyword.  Do you REALLY find
> >
> >     while (line := file.readline()) != 'end':
> >         process_line(line)
> >
> > to be less readable than
> >
> >     while 1:
> >        line = file.readline
> >        if line == 'end': break
> >        process_line (line)
> >
> > (or worse, imagine several nested loops like that)?  I don't.
>
> I do.
>
> I find assignment within an expression to be contrived and opaque.  I
> would be surprised if there were many of your opinion who weren't
> numbed down to it by years of exposure to C.
>
Well, it isn't just C. Some readers of this list remember the Icon language,
in which (unlike Python) pretty much everything was an expression: iterative
constructs had as their value the value of the last expression evaluated
inside, for example. In fact Icon is much more expression-oriented than C.
But I don't feel "numbed" by my exposure to it...

The real point here is that Python is, *by design choice*, not an
expression-oriented language. I suspect this is why attempts to retrofit
assignments into while seem so artificial.

Until someone proposes something that seems like a natural fit with the
Python we already have (which, IMHO, constructs using semicolons do not), I
don't think there's enough reason to change.

regards
 STeve
--
http://www.holdenweb.com/








More information about the Python-list mailing list