Geneator/Iterator Nesting Problem - Any Ideas? 2.4

Peter Otten __peter__ at web.de
Mon Mar 7 11:22:16 EST 2005


ChaosKCW wrote:

> def resultset_functional_generator(cursor):
>     for rec in iter(lambda: cursor.fetchone(), None):
>         yield rec

This can be simplified to
 
def resultset_functional_generator(cursor):
    return iter(cursor.fetchone, None)

It should be a bit faster, too.

Peter




More information about the Python-list mailing list