Unlike the C programming language, Python assignments are statements, not expressions. Therefore the common C idiom of:
while (line = fgets(f)) {
/* do something with the line */
}
is not possible to implement directly.
However, effbot.org provides several alternatives using iterators or the while True idiom. I recently discovered the built-in iter() function as well:
for line in iter(f.readline, "END"):
... do something with line ...