On Jan 21, 1:55 pm, Peter Otten <__pete...@web.de> wrote: > Falcolas wrote: > > I tried overriding __getattr__ and got an error at runtime (the > > You can either move __getattr__() into the metaclass or instantiate the > class. I prefer the latter. > > Both approaches in one example: > > >>> class Tag: > > ... class __metaclass__(type): > ... def __getattr__(self, name): return "<%s> via metaclass" % > name > ... def __getattr__(self, name): return "<%s> via class" % name > ...>>> Tag.yadda > > '<yadda> via metaclass'>>> tag = Tag() > >>> tag.yadda > > '<yadda> via class'
Very nice, thanks! -- http://mail.python.org/mailman/listinfo/python-list