En Fri, 28 Mar 2008 12:15:45 -0300, Stef Mientki <[EMAIL PROTECTED]> escribió:
> Passing all kinds of data between objects, > I'm looking for an elegant (and simple) way to pack the data. > Now it looks to me that both the class and the inherited list, > performs equally well. > Till now, the most elegant way (in my view) is the list inheritance, > mainly because you don't need brackets and no quotes. > What are others opinion about this ? > > class super_list(list): > pass > > def kwadraat ( value ) : > return value * value > > x={} > x['frequency']=33 > x['functie']=kwadraat > print x['functie'](2) > > y = super_list() > y.frequency = 33 > y.functie = kwadraat > print y.functie(3) You don't use y as a list at all - you might as well inherit from object. And in that case you get a generic attribute container - as you said, like a dict but using attribute syntax (drawback: only valid names can be used as keys) But I don't understand the "functie" usage - what's for? Perhaps if it used y.frequency - in that case a proper method would be better. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list