8.4. Decorator About Object

  • Decorating function

  • Decorating class

  • Decorating method

8.4.1. Decorating Function

  • By convention func or fn

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

8.4.2. Decorating Class

  • By convention cls

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

8.4.3. Decorating Method

  • By convention mth, meth or method

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