__parent__ - like attribute?
pyth at devel.trillke.net
Sun Jan 19 12:43:32 CET 2003
Dylan Reinhardt wrote:
> To recap/clarify:
> I have several instances of spam, each of which contains (let's say) many
> thousands of instances of eggs. I want for changes made to a single
> instance of eggs to be made known to the specific instance of spam that
> contains it. Similarly, I want for any instance of eggs to be able to get
> the value of any attribute of its containing spam object.
> To put this more generally, I want a subobject to find its containing
> object so that methods of the containing object can be called and
> attributes of the containing object can be set/checked. I gather there's no
> easy, pre-defined way to do this, so any namespace voodoo that can do the
> trick would be most welcome.
if you want a contained object to at some point know about its
container then you should pass the contained object an explicit
reference of its container. This is simple.
Otherwise, I recommend that you try to come up with a small real
More information about the Python-list