Martin v. Löwis wrote: > If you want to, you can combine this with the factory/singleton > patterns, to transparently create the objects on first access: > > class Registry: > def __getitem__(self, name): > # only invoked when attribute is not set > r = pin(name) > setattr(self, name, r) > return r > registry = Registry() > > class pin: > def __init__(self, name): > self.name = name > > print registry.aap
<nitpick> You probably meant __getattr__ instead of __getitem__ here ;) </niptick> This is an interesting approach, but I would probabily use the traditional registry you discussed before (too much magic here). Michele Simionato
-- http://mail.python.org/mailman/listinfo/python-list