dict_proxy({.....'showMe4': 'function wrapper1 at 0x0C1BD150',
'showMe3': 'classmethod object at 0x0C1BF630'.....
为什么如果我使用包装器定义自己的装饰器(例如 wrapper1
) 用于我的函数(例如 showMe4
) 在某些类中(例如 myClass
) 它在 myClass.__dict__
中被列为函数,但 Python 装饰器如 @classmethod
和 @staticmethod
(我假设所有 Python 定义的装饰器?)如果应用于我的函数(例如,将@classmethod
应用于showMe3
)被列为对象?
装饰器可以是函数或类(实现__call__
)。在后一种情况下,修饰函数实际上是用于装饰函数的类的实例。