装饰器 decorator - noonecare/python GitHub Wiki

装饰器/decorator

函数用作装饰器

类作为装饰器

functools.wraps 函数保证函数的属性(包括 docstring , annotations 等)不变

MetaClass

  • 对象的创建:

  • 类的创建:

常用装饰器

  • @classmethod
  • @staticmethod