class Test:
def creat_role(self,ctx):
print("ctreate_role")
loading_bar(self.update_mute(ctx), ctx)
def update_mute(self, ctx):
print(f"update_mute {ctx}")
def loading_bar(func, ctx):
print("loading_bar")
def decorator():
print("decorator")
func()
for i in range(1, 6):
print("finish")
return decorator
if __name__ == "__main__":
Test().creat_role(123)
ctreate_role
update_mute 123
loading_bar
ctreate_role
loading_bar
decorator
update_mute 123
finish x6
class Test:
def creat_role(self,ctx):
print("ctreate_role")
loading_bar(self.update_mute)(ctx)
# self.update_mute(ctx)
# @loading_bar
def update_mute(self, ctx):
print(f"update_mute {ctx}")
def loading_bar(func):
print("loading_bar")
def decorator(*args, **kwargs):
print("decorator")
func(*args, **kwargs)
for i in range(1, 6):
print("finish")
return decorator
loading_bar(self.update_mute)(ctx)
, а # self.update_mute(ctx)
# @loading_bar
раскомментировать