I have a Python class
class A:
def __init__(self, auth):
self.auth = auth
I want to use the auth
variable as a function decorator but when I do something like below, it gives and error:
@self.auth.some_method()
def func(self):
pass
the above does not work. Can someone please help with this. Thanks
I'd suggest doing something like this:
class A:
def __base_func(self):
pass
def __init__(self, auth):
self.auth = auth
self.func = auth.some_method(self.__base_func)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.