I know I can write code like:
class A : def __getattr__ (self, name) : return name
to trap access to undefined attributes on an
Yes you can. Metaclasses are the answer.
class MyMetaclass(type): def __getattr__(cls, name): return "cls.%s" % name class A : __metaclass__ = MyMetaclass def __getattr__ (self, name) : return name print A().ATTR print A.ATTR
will output
ATTR cls.ATTR