Closures:
Two nested functions, external functions return the internal function of the argument, external function?
def external function (parameter):
def intrinsic function ():
Pass
return intrinsic function
The difference between him and the function:
1. Format two nested functions
2. Parameters of the closure external function can be persisted in memory
What the adorner is: Closure plus @xxx
The work of the decorator: To add additional functionality without changing the original function value
The code for the adorner:
def set_fun (func):
def call_fun (*args,**kwargs):
return func (*args,**kwargs)
Return Call_fun
@set_fun
def test ():
Pass
1. Pre-decoration function test, which is directed by the Func 2. The function test after the decoration, the actual is Call_fun 3. Pre-decoration test, after the decoration test, after the decoration of the test (Call_fun) three to maintain? 4. The adorner cannot change the function's tune? Type and return value
The understanding of a function of a decorator?
A decorative decorator? A diagram of a function:
A decorator decorator? A function memory graph to understand:
Understanding of Python closures and adorners