I want to add a method to a class. This method contains 'self' which is referred to the class instance itself:
def func(self, t):
return self.b + t
class A:
pass
a = A()
a.b = 10
a.foo = func
print(a.foo(3))
When I run the code above I get the error:
TypeError: func() missing 1 required positional argument: 't'
What's wrong with my code? Thanks!