self-registering objects?
Ionel Simionescu
ionel at psy.uva.nl
Fri Oct 29 15:56:37 EDT 1999
Hi,
I would like objects of a certain class to be able of registering themselves
in a global dictionary, __register__, possibly upon __init__.
__register__ should contain associatins such as:
{ 'ID': <__main__.certain_class instance at ####> }
Unfortunately, the naive:
def __init__(self, etc.):
global __register__
self.ID = 'instance1'
__register__[self.ID] = self
Does NOT work.
The object that I find in the __register__ under the given ID is apparently
just the bare bones of the class and gets none of the changes incured to the
instance after registration.
It's is not a problem if I register the object "from outside",
but I would like to understand what's going on...
ionel
More information about the Python-list
mailing list