title: Method decorator to register callbacks
body: <p>I'm working on a callback system in Python. The to-be callbacks are methods of a class. I register these with a decorator.
  Here is some pseudo class representing this:</p>
  <pre><code>class MyClass(ABC):
    def __init__(self):
      self.cb_stack = {}
  
    def register_callback(self, callback, name):
      self.cb_stack[name] = callback     
  
    @register_callback('mycb')
    def myCallback(self, input):
      self.do_things()
  </code></pre>
  <p>I suspect each decorator is executed by default.</p>
  <p>I would like however for the decorator to be executed when <code>obj.myCallback()</code> is called, and to prevent <code>myCallback()</code> from executing at that moment (which should be the case here).</p>
  <p>The alternative I have is to write it in the long form for each callback, which should work like so:</p>
  <pre><code>class MyClassLong(ABC):
    def __init__(self):
      self.cb_stack = {}
  
    def register_callback(self, callback, name):
      self.cb_stack[name] = callback     
  
    def myCallback(self):
      def func(self, input): 
        self.do_things()
      self.register_callback(func, 'mycb')
  </code></pre>
  <p>Notice it adds two lines of codes, so it's not really an issue but more how to make something clean.
  Does anyone knows how if it is achievable, and how ?</p>