Conditional Expressions don't solve the problem

Fredrik Lundh fredrik at pythonware.com
Wed Oct 17 11:47:59 EDT 2001


Paul Rubin wrote:

> 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)

yes.

even if Python had a := operator, both examples would be
seriously broken.  broken code isn't readable.

and the "while 1" pydiom usually doesn't look that way.

(for some reason, people attacking it always do the same mis-
take.  probably a newbie thing: once you start using Python to
write pydiomatic Python code instead doing things the C/Java
way, it's not a real problem).

and you really should learn about iterators.

(and this is my only post on this topic, promise ;-)

</F>





More information about the Python-list mailing list