Created
August 24, 2022 18:45
-
-
Save dword4/c44fcb3bb07a4e447808d0535925a2d3 to your computer and use it in GitHub Desktop.
Revisions
-
dword4 created this gist
Aug 24, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/usr/bin/env python3 class command(object): def ratelimit(*args, **kwargs): limit = args[0] def ratelimit_wrapper(func): print(f"rate: {limit}") print("begin: ratelimit_wrapper") # some stuff print("end: ratelimit_wrapper") return func return ratelimit_wrapper class animals(object): @command.ratelimit(10) def cat(self): print("meow") @command.ratelimit(5) def dog(self): print("woof") zoo = animals() zoo.cat() zoo.dog() zoo.cat() This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ ./dec.py rate: 10 begin: ratelimit_wrapper end: ratelimit_wrapper rate: 5 begin: ratelimit_wrapper end: ratelimit_wrapper meow woof meow