1 definitions
Definition: In computer science, closures are abbreviations for lexical closures and are functions that reference free variables.
Simply put: A closure is a function that reads the internal variables of other functions, and a closure is a bridge that connects the inside of the function to the outside of the function. --Source Baidu Encyclopedia
2 description
Conditions for the formation of closures:
1. Closures must have intrinsic functions
2. The variable of the outer function must be referenced in the intrinsic function, that is, the free variable
3. The outer function must say that the inner layer function returns
Advantages:
1. Extended the life cycle of local variables
2. Enhanced Encapsulation
Disadvantages:
1. Increased memory burden
2. Intrinsic functions can modify the external function variables, prone to error modification
Python Learning notes-closures