title: Python, How to pass function to a class method as argument
body: <p>I am trying write a signal processing package, and I want to let user creates a custom function without needing to access the class file :</p>
  
  <pre><code>class myclass():
      def __init__(self):
          self.value = 6
      def custom(self, func, **kwargs):
          func(**kwargs)
          return self
  
  c = myclass()
  def add(**kwargs):
      self.value +=  kwargs['val']
  
  kwargs = {'val': 4}
  c.custom(add, **kwargs )
  print (c.value)
  </code></pre>
  
  <p>I got name 'self' is not defined. Of course because func is not a method to the class. But I am not sure how to fix it. Please advice. </p>
  
  <p>Thanks</p>