Day17 Decorator

  • decorator

Decorators are essentially functions

Function: Decorate other functions, add additional functionality to other functions

in principle:

  1. The source code of the decorated function cannot be modified
  2. Cannot modify the way the decorated function is called

Implement decorator knowledge reserve:

  1. Functions are "variables"
  2. Higher order functions
  3. nested functions

Higher-order function + nested function ---> decorator

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324804314&siteId=291194637