DrConti wrote: > Hi Bruno, hi folks! > thank you very much for your advices. > I didn't know about the property function. > I learned also quite a lot now about "references". > Ok everything is a reference but you can't get a reference of a > reference... > > I saw a lot of variations on how to solve this problem, but I find > actually that the "property approach" is the most natural of all.
So I need to add a little correction to the code snippet (sorry, got confused by your namings - ie 'ObjectClass' - and some recent exploration I did about per-instance descriptors) : Actually, using a property as an *instance* attribute won't work - unless the class redefine __getattribute__ this way: class ObjectClass(object): def __getattribute__(self, name): v = object.__getattribute__(self, name) if not isinstance(v, types.FunctionType) \ and hasattr(v, '__get__'): return v.__get__(self, self.__class__) return v > Basically the idea there is that you build up this list of class > attributes These are not *class* attributes, but *instance* attributes. I think you should really take some time to learn more about Python's object model, attribute lookup rules, descriptors and metaclasses. -- bruno desthuilliers python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for p in '[EMAIL PROTECTED]'.split('@')])" -- http://mail.python.org/mailman/listinfo/python-list