1👍
✅
You could use a class decorator to register your methods instead:
def register_methods(cls):
for name, method in cls.__dict__.items():
# register the methods you are interested in
@register_methods
class Foo(object):
def x(self):
pass
You could combine this with a method decorator to annotate the methods you are interested in so you can easily identify them.
As an aside you mention @classmethod
, which is a built-in decorator that returns a function which takes a class as it’s first argument. In this case you probably don’t want to use (or emulate) it.
Source:stackexchange.com