Auto-register class methods using decorator
Here’s a little love for class decorators. I think the syntax is slightly simpler than that required for metaclasses. def class_register(cls): cls._propdict = {} for methodname in dir(cls): method = getattr(cls, methodname) if hasattr(method, ‘_prop’): cls._propdict.update( {cls.__name__ + ‘.’ + methodname: method._prop}) return cls def register(*args): def wrapper(func): func._prop = args return func return wrapper … Read more