Carsten Haese wrote: > On Wed, 2007-07-25 at 19:26 +0000, Neil Cerutti wrote: >> Speaking of the iter builtin function, is there an example of the >> use of the optional sentinel object somewhere I could see? > > Example 1: If you use a DB-API module that doesn't support direct cursor > iteration with "for row in cursor", you can simulate it this way: > > for row in iter(cursor.fetchone, None): > # do something > [...] This would, of course, be a horribly inefficient way to handle a database result with 1,500,000 rows. Calling fetchall() might also have its issues. The happy medium is to use a series of calls to fetchmany(N) with an appropriate value of N.
regards Steve -- Steve Holden +1 571 484 6266 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://del.icio.us/steve.holden --------------- Asciimercial ------------------ Get on the web: Blog, lens and tag the Internet Many services currently offer free registration ----------- Thank You for Reading ------------- -- http://mail.python.org/mailman/listinfo/python-list