__parent__ - like attribute?
Dylan Reinhardt
python at dylanreinhardt.com
Sun Jan 19 00:52:00 EST 2003
More information about the Python-list mailing list
Sun Jan 19 00:52:00 EST 2003
- Previous message (by thread): How to convert string to float in Python 1.2
- Next message (by thread): __parent__ - like attribute?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
At 09:00 PM 1/18/2003, Dennis Lee Bieber wrote: > My understanding was that he wants changes /in/ the eggs instance to >affect the "changed" attribute of the spam instance. Yes, exactly. > To which my response is: What is > >c = eggs() >c.do_stuff() > >supposed to be changing? The global namespace? I don't think so... but if that gets me where I need to go, I'm all ears. :-) >class eggs(spam): > def __init__(self): > spam.__init__(self) > > def do_stuff(self): > self.changed = 1 > ... I doubt inheritance will do the trick here. Spam isn't a base class, it defines a container object. 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. Thanks, Dylan
- Previous message (by thread): How to convert string to float in Python 1.2
- Next message (by thread): __parent__ - like attribute?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list