Conditional Expressions don't solve the problem
idot at vt.edu
Wed Oct 17 20:07:27 CEST 2001
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':
> 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 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