我有三个python函数:
def decorator_function(func)
def wrapper(..)
return func(*args, **kwargs)
return wrapper
def plain_func(...)
@decorator_func
def wrapped_func(....)
在模块 A 中。
现在我想获取这个模块 A 中的所有功能,为此我做了:
for fname, func in inspect.getmembers(A, inspect.isfunction):
# My code
这里的问题是 func 的值不是我想要的。
它将是 decorator_function、plain_func 和 wrapper(而不是 Wrapped_func)。
如何确保返回 Wrapped_func 而不是 wrapper?