def TupleRow(cursor):
 class Row(tuple, ):
  cursor_description = cursor.description
  def get(self, field):
   if (not hasattr(self, 'field_dict')):
    self.field_dict = {}
    for (i, item) in enumerate(self):
     self.field_dict[self.cursor_description[i][0]] = item
   return self.field_dict.get(field)
  def __getitem__(self, field):
   if isinstance(field, (unicode, str)):
    return self.get(field)
   else:
    return tuple.__getitem__(self, field)
 return Row

def TupleRow ( cursor ) : class Row ( tuple , ) : cursor_description = cursor . description def get ( self , field ) : if ( not hasattr ( self , 'field_dict' ) ) : self . field_dict = { } for ( i , item ) in enumerate ( self ) : self . field_dict [ self . cursor_description [ i ] [ 0 ] ] = item return self . field_dict . get ( field ) def __getitem__ ( self , field ) : if isinstance ( field , ( unicode , str ) ) : return self . get ( field ) else : return tuple . __getitem__ ( self , field ) return Row
normal tuple with added attribute cursor_description .