Python Fifth day

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.