Re: [Tutor] references to containing objects

2008-06-23 Thread Kent Johnson
On Mon, Jun 23, 2008 at 12:17 AM, John Gunderman <[EMAIL PROTECTED]> wrote: > I am looking for a way to tell a object the properties of its containing > object. > For example, I have an object foo, of class Bar, which I have stored in a > dict > in the object I want to access. Basically: > > contai

Re: [Tutor] references to containing objects

2008-06-23 Thread Chris Fuller
You can also subclass the dictionary type so that this happens transparently. You could do something similar with lists. class Container(dict): def __setitem__(self, key, value): dict.__setitem__(self, key, value) if hasattr(value, 'setParent'): if callable(value.setPare

Re: [Tutor] references to containing objects

2008-06-23 Thread Alan Gauld
"John Gunderman" <[EMAIL PROTECTED]> wrote I am looking for a way to tell a object the properties of its containing object. Can you explain why. Thats usually a bad idea. At the very least it should call a method of the containing object rather than "access its properties" (assuming you mean