Imagine I have a mysql cursor and data read. The amount of data might be very big that I want to deal with one line each time.
An easy and straight forward way might
The MySQLdb cursor class implements the iterator protocol, so you can simply do this:
MySQLdb
cursor.execute(sql) for row in cursor: print row ...
Relevant code from MySQLdb.cursors.BaseCursor:
def __iter__(self): return iter(self.fetchone, None)