The Python Road, Day4 - Python Basics 4

Reference address:

http://www.cnblogs.com/alex3714/articles/5765046.html

Contents of this section:

decorator

Definition: The essence is a function, (decorating other functions) is to add additional functions to other functions.

Principles: 1. The source code of the decorated function cannot be modified.

          2. The calling method of the decorated function cannot be modified.

        (In short: the original function does not feel that it has been modified)

Implement decorator knowledge reserve: higher-order function + nested function = "decorator

        1. Functions are variables

        2. Higher-order functions: A higher-order function is a function that satisfies one of the following conditions

            a. Pass a function name as an argument to another function

            b. The return value contains the function name

        3. Nested functions

Guess you like

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