Documentation, assignment in expression.

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


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


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?


More information about the Python-list mailing list