I just came across this piece of code
while 1: line = data.readline() if not line: break #...
and thought, there must
This isn't much better, but this is the way I usually do it. Python doesn't return the value upon variable assignment like other languages (e.g., Java).
line = data.readline() while line: # ... do stuff ... line = data.readline()