class MyDecorator(Decorum):
...
class A:
@MyDecorator
def foo(self, x):
...
a = A()
a.foo("bar")
... it would fail, because x would be passed to self when foo was called by the decorator. By overriding the __get__ method, we can keep the original instance (a) in the partial function returned. This works with both decorated instance methods and naked methods.
Previously, if you decorated a method like so:
... it would fail, because
x
would be passed toself
whenfoo
was called by the decorator. By overriding the__get__
method, we can keep the original instance (a
) in the partial function returned. This works with both decorated instance methods and naked methods.