5th Chapter
1.first-class function
The first-class here means that a function can act as an object and return in another function.
Metaclass programming also has the concept of first-class class, which means that a class can be created as an object in another class, returning
2. Function parameters
6th Chapter
Strategy and Command are similar in design mode, but the focus is different.
Strategy mode:
Focusing on the substitution of algorithms, the algorithm can be encapsulated as a function object, which can be replaced by a function object.
Command mode:
involving Invoker and receiver
Seventh Chapter
Always feel a bit around, see understand, write the time can not write, so back down these two classic wording
The classic notation of decorator without parameters
def decoratorfunctionname (func): @functools. Wraps (func) def wrapper (*args, **kwargs): * * * Front code * * * return func (*args, **kwargs) return wrapper
The classic notation of decorator with parameters
def decoratorfunctionname (decoratorarguments): def Decorator (func): @functools. Wrapper (func) def Wrapper (*args, **kwargs): The decoratorarguments*** return func (*args, **kwargs) return can be used in the pre-built code Wrapper return Decorator
Python functions as objects