Conditional Expressions don't solve the problem

Carl Banks idot at
Wed Oct 17 20:07:27 CEST 2001

Paul Rubin <phr-n2001d at> 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.


More information about the Python-list mailing list