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 :
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)
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.
Thanks