[Python-3000] Iterators for dict keys, values, and items == annoying :)

Greg Ewing greg.ewing at canterbury.ac.nz
Thu Mar 30 05:36:55 CEST 2006


Ian Bicking wrote:

> Which is off-topic here, except to say that a view on the tuple would be 
> useful in a way that returning a fancy tuple would not, because it could 
> wrap any DB-API-compliant result set.

A wrapper like that could be built quite generically.
Also, better to wrap the whole sequence, I think,
rather than each tuple individually:

   results = tableview(mycursor, 'price', 'upc')
   for row in results:
     print row.price, row.upc

Something for the itertools module, perhaps? (It
would need to be an iterator wrapper, not a
sequence wrapper, to work on DB cursors etc.)

-- 
Greg Ewing, Computer Science Dept, +--------------------------------------+
University of Canterbury,	   | Carpe post meridiam!          	  |
Christchurch, New Zealand	   | (I'm not a morning person.)          |
greg.ewing at canterbury.ac.nz	   +--------------------------------------+


More information about the Python-3000 mailing list