list extension ?
- From: Stef Mientki <stef.mientki@xxxxxxxxx>
- Date: Sun, 29 Jun 2008 23:03:19 +0200
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
.
- Follow-Ups:
- Re: list extension ?
- From: Bruno Desthuilliers
- Re: list extension ?
- From: Scott David Daniels
- Re: list extension ?
- Prev by Date: Re: gelato - nvidia and python
- Next by Date: Re: list extension ?
- Previous by thread: Function to import module to namespace
- Next by thread: Re: list extension ?
- Index(es):