【发布时间】:2018-01-17 13:49:42
【问题描述】:
我想了解这段代码中的装饰器行为
abc.py
def my_decorator_module(some_function):
def wrapper():
num = 10
if num == 10:
print('yess')
else:
print('no')
some_function()
print('print after some_function() called')
return wrapper()
并将这个函数称为装饰器
x.py
from abc import my_decorator_module
@my_decorator_module
def just_some_function():
print("Wheee!")
输出是
yess
Wheee!
print after some_function() called
执行x.py文件时我没有在x.py文件中调用just_some_function()的事件返回我的输出,为什么?
【问题讨论】:
标签: python python-3.x decorator