Yeild: Returns a Generator object;
Adorner: itself is a function that functions to decorate other functions (calling other functions)
Function: Enhance the function of the decorated function
Adorners generally accept a function object as a parameter, so that it can be enhanced
@ The original function name to invoke other functions
Recursion: Recursive requires boundary condition, recursive forward segment and recursive return segment;
10*9*8*7*6*5*4*3*2*1
10*9
10* (10-1) * (10-1)-1)
Co-process:
Design Specifications for Functions:
Coupling:
(1) The input is accepted by the parameter, and the output is produced by return to ensure the independence of the function;
(2) Minimizing the use of global variables for inter-function communication;
(3) Do not modify the parameters of the variable type in the function;
(4) Avoid directly changing the variables defined in another module;
Polymerization of
(1) Each function should have a single, unified goal;
(2) The function of each function should be relatively simple;
Exercises:
1: Each line in the/etc/passwd file is divided into a list;
2: Separate each row into a list by user-specified delimiter;
3: Use the Folding method (reduce) to find factorial;
Python Learning Notes (yield and adorner)