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

Alex Martelli aleaxit at gmail.com
Thu Mar 30 04:23:53 CEST 2006


On Mar 29, 2006, at 6:03 PM, Greg Ewing wrote:

> On 3/29/06, Adam DePrince <adam.deprince at gmail.com> wrote:
>
>>>>> rs.execute( "select upc, description, price from my_table" )
>>>>> data = rs.fetch().fieldby( 'price','upc')
>>>>> print type( data )
>>
>> <MultiViewMapping>
>
> Seems to me it would be a better idea for the DB
> module to return tuple-with-attributes objects for
> the rows in the first place, rather than plain
> tuples.
>
> When I get around to reworking my custom Firebird
> module, I'm going to make it do that.

It does indeed seem a great idea for a lot of tuples to sprout  
attributes in this way.

Do we have any plans to make the "attributeing" of tuples easier for  
C extension writers? What about Python programmers? Looks like a  
simple metaclass should suffice, and we might have somewhere in the  
stdlib a class to inherit from in order to get the appropriate  
metaclass -- module 'types' seems the natural place for it.


Alex




More information about the Python-3000 mailing list