Reference Blog Address: http://www.cnblogs.com/wupeiqi/articles/4980620.html
1. Write code to follow the open closure principle , in short, the provisions have been implemented function code is not allowed to be modified, but can be extended, namely:
closed: Implemented function code block
Open: for extended development
2. the adorner completely replaces the F1 function, and then adds the F1 function body to its function body, as shown in 1:
PS: Note the order in which the code is executed
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/85/2F/wKiom1ecMavTEsi8AABbxohgsdg732.png-wh_500x0-wm_3 -wmp_4-s_370473146.png "title=" 1.png "alt=" Wkiom1ecmavtesi8aabbxohgsdg732.png-wh_50 "/>
Figure 1
Decorator Understanding Customization Figure 2: Overwrite the original F1 function with the function defined by the adorner, so that additional functions can be executed before and after executing the F1 function. Has no relation to the original function.
650) this.width=650; "Src=" Http://s3.51cto.com/wyfs02/M01/85/2F/wKioL1ecMhvxCZTHAAAXUidzA-w992.png-wh_500x0-wm_3 -wmp_4-s_3003091743.png "title=" 2.png "alt=" Wkiol1ecmhvxczthaaaxuidza-w992.png-wh_50 "/>
Figure 2
3. using the Universal parameter *args,**kwargs to solve the parameter number of the non-uniform situation.
4. Double- decked decorator
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/85/2F/wKiom1ecMkSC8V24AACI5bdy8XQ931.png-wh_500x0-wm_3 -wmp_4-s_1169749436.png "title=" 3.png "alt=" Wkiom1ecmksc8v24aaci5bdy8xq931.png-wh_50 "/>
5. Multilayer Decorative Device
6. More Awesome decorators-can add parameters
Cond
Python Learning-Decorators