Documentation, assignment in expression.

Alexander Blinne news at blinne.net
Fri Mar 23 23:59:44 CET 2012


Hi,

I think this section of the docs needs some kind of rewrite:

<http://docs.python.org/faq/design.html#why-can-t-i-use-an-assignment-in-an-expression>

While it is great to discuss the reasons for not allowing an assignment
in an expression, I feel that the given example is some kind of
outdated. The last sentence "For example, in the current version of
Python file objects support the iterator protocol, so you can now write
simply (for line in file:)" makes me think that this section was written
while that syntax was still new. No one I know would ever write
something like this:

> while True:
>     line = f.readline()
>     if not line:
>         break
>     ... # do something with line

I think at least we need a new example. Any ideas?

Greetings
Alexander



More information about the Python-list mailing list