Skip to content

Instantly share code, notes, and snippets.

@GameXG
Last active February 21, 2017 02:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GameXG/ed84b114067fb4a7b398cb811a9241ca to your computer and use it in GitHub Desktop.
Save GameXG/ed84b114067fb4a7b398cb811a9241ca to your computer and use it in GitHub Desktop.
def w(a = 234):
if callable(a):
# 目的是当用户 @w 时也有效。
return w()(a)
def ww(func):
@wraps(func)
def fffff( *args, **kwargs):
print (a)
return func(*args, **kwargs)
return fffff
return ww
@w(123)
def hello3():
"""test hello 3"""
print ('hello world3')
# 实际这里 hello3 已经变成了 fffff 函数。
# 所以会先输出 123 再输出 hello world3。
hello3()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment