Python path-Generator

Source: Internet
Author: User
List generation: [F (x) for I in range (k)]>>> where k is constant, f (x) is a constant about I use a function to implement a generator:
def fib (max): N,a,b = 0,0,1 while N<max:yield b #关键 yield has a hold value and returns a, B = b,a+b n + = 1 return "error" through the generator's __next__ () method Returns
the parallel operation of the error message generator: The generator sends the value Val to yield by means of the Send (Val) method, and assigns the Val value to the yield expression: A, B = b,a+b equivalent to T = (b,a+b) a = t[0] [= t[1]
  • The generator generates the corresponding data only when it is called
  • The generator only records the current location
  • Generator only __next__ () one method

Python path-Generator

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.