Hello, I have a decorator problem and hope someone is able to help me out/ assist me. Thanks in advance.
Suppose: ### Begin some_library_module ### def some_decorator(some_method): def inner(an_arg, *args, **kwargs): return some_method(an_arg, *args, **kwargs) return inner ### End some_library_module ### ### Begin my_module ### def my_decorator(some_method): def inner(self, an_arg, *args, **kwargs): self.do_something() return some_decorator(some_method)(an_arg, *args, **kwargs) return inner class My_Class(object): @my_decorator def my_method(self, an_arg, *args, **kwargs): print self, an_arg def do_something(self): pass ### End My_module ### >>> My_Class().my_method('bla') TypeError: my_method() takes at least 2 arguments (1 given) `self` is lost in the process, because my decorator does use it and the library's doesn't. I fail to find a way to keep self in the args without modifying the library. -- http://mail.python.org/mailman/listinfo/python-list