Last active
July 4, 2019 07:49
-
-
Save xin053/c02c680d5e6b008871caa8d0472c527d to your computer and use it in GitHub Desktop.
[python 装饰器]注册装饰器 #python #装饰器
This file contains 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 characters
_functions = {} | |
def register(f): | |
global _functions | |
_functions[f.__name__] = f | |
return f | |
@register | |
def foo(): | |
return 'bar' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment