Open Closure principle
Development: For non-existent open
Closed: Closed for code that already exists
Decorative Device
1, the adorner is a function, at least 2 layers
2.
Execute auth function, decorated function as parameter auth (foo)
The return value of the AUTH function, assigned to the function name of the decorated function
@auth
def foo ():
Pass
3, dynamic parameters, can decorate a function containing n parameters
4. function return value
5, multi-Adorner
6, multilayer decorative device.
def Filter (A1,A2):
def outer (Main_func):
def wrapper (Request,kargs):
Print A1
Main_result = Main_func (Request,kargs)
Print A2
Return Main_result
Return wrapper
return outer
@Filter (F5, F6)
def Index (Request,kargs):
print ' index '
1, the adorner is a function, at least 2 layers
2.
Execute auth function, decorated function as parameter auth (foo)
The return value of the AUTH function, assigned to the function name of the decorated function
@auth
def foo ():
Pass
3, dynamic parameters, can decorate a function containing n parameters
4. function return value
5. Multi-adorner--box model
6, at least 3 layers, 3 layers of how to use?
@w1
1. Execute W1 function
2. Assign the return value of the W1 function to the function name of the decorated function
@w2 (ARG)
1, execute W2 function, get return value, ret
2, create the adorner, @ + RET combination; @ret
3 、。。。
1. Perform RET function
2. Assign the return value of the RET function to the function name of the decorated function
Remote Module Paramiko
Module definition
A collection of all code that implements a function and is implemented
Existence mode
1. py file
2. Folders
View python default look for module location
Sys.path
Automatically add files to the path list
Normal folder can not be a module, need to have __init__.py, to be imported, it is possible to become a module. This file is generally empty
1. Encryption
2, the decorative device
3. Product Classification
Configpres
Python Fifth day