【发布时间】:2016-02-02 09:51:26
【问题描述】:
我想通过调用我的 decorate 来构建一个 view_functions 字典!
view_functions = {}
def route(rule):
def _route(function_name):
def __route(function_arg):
view_functions[rule] = function_name
return __route
return _route
if __name__ == '__main__':
@route('hey')
def hello(arg):
print 'hello ',arg
#hello('ap') if you have no call the function directly,you will got view_function have no key 'hey' ...That's my question!
view_functions['hey']('pp')
我怎样才能简单地将装饰放在 view_function 上方(就像 Flask 一样),然后我的 view_functions 字典会自动填充?
【问题讨论】: