thanks Gabriel, Gabriel Genellina wrote: > 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. Good point, didn't notice that. > > 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) > Perfect, I don't need invalid names. > 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. > In my case the sender of the data determines the function ("functie" is the Dutch word for "function"), assume this concept: Sender: - generates a huge array of data Receiver: - is a plot utility with interactive user interface - the user can select a part of the huge dataset and wants to see the result of "function" on the selected part of the huge dataset So by passing the function-name(s), I prevent that the functions(s) should be performed on all the data. while they will never be used.
cheers, Stef Mientki -- http://mail.python.org/mailman/listinfo/python-list