Python Learning Notes (yield and adorner)

Source: Internet
Author: User

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)

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.