在Windows XP(sp3)计算机上使用Python 3.4.4,以下代码使用基本装饰器进行教育,显示双倍输出,我不知道为什么:
def decorated_by(func):
func.__doc__ += '\nDecorated by decorated_by!!!'
return func
@decorated_by
def add(x, y):
'''Return the sum of x and y.'''
return x + y
add = decorated_by(add)
print (help(add))
输出:
C:\>python test30.py
Return the sum of x and y.
Decorated by decorated_by!!!
Decorated by decorated_by!!!
代码正在命令行的文件中运行。
感谢。