Items inheriting attributes from its container?
bruno.42.desthuilliers at websiteburo.invalid
Mon Aug 24 10:44:21 CEST 2009
Kreso a écrit :
> I would like to create a list-like container class so that, additionally
> to usual list methods, I could attach attributes to the container instances.
> However, I would like it so that the items contained in the particular
> instance of container somehow 'inherit' those attributes i.e.
> cont = Container()
> cont.color = 'blue'
> print item.color
This is named "environmental aquisition" (or simply "aquisition") and is
one of the base mechanisms in Zope 2. While an interesting idea, from
experience, it can rapidly turn into a total maintainance nightmare if
not used with care :-/
More information about the Python-list