list extension ?
Stef Mientki
stef.mientki at gmail.com
Sun Jun 29 17:03:19 EDT 2008
hello,
I basically need a list with a few extra attributes,
so I derived a new object from a list, and it works perfect.
But I wonder why the newly derived list component is much more flexible ?
# so here is the new list object
class tGrid_List ( list ) :
def __init__ ( self, value = [] ) :
list.__init__ ( self, value )
# and with this new list component, I can add new attributes on the fly
a = tGrid_list ( [ 2, 3 ] )
a.New_Attribute = 'some text'
# I'm not allowed to this with the standard list
a = [ 2, 3 ]
a.New_Attribute = 'some text' <== ERROR
Can someone explain this different behavior ?
thanks,
Stef Mientki
More information about the Python-list
mailing list