5.4. Decorator About Object

  • Decorating function

  • Decorating class

  • Decorating method

5.4.1. Decorating Function

  • By convention func or fn

>>> def mydecorator(func):
...     ...
>>> class MyDecorator:
...     def __init__(self, func):
...         ...

5.4.2. Decorating Class

  • By convention cls

>>> def mydecorator(cls):
...     ...
>>> class MyDecorator:
...     def __init__(self, cls):
...         ...

5.4.3. Decorating Method

  • By convention mth, meth or method

>>> def mydecorator(mth):
...     ...
>>> class MyDecorator:
...     def __init__(self, mth):
...         ...