Python iterator generator (3), python Generator

Source: Internet
Author: User

Python iterator generator (3), python Generator

Extended list parsing syntax

Continue writing today and yesterday.

List parsing can become more complex-for example, it can contain nested loops or be written as a series of for clauses. (Here is a brief introduction to this syntax)

For example, to construct an x + y join table, connect each x in a string with every y in another string. It effectively collects the character arrangement of two strings:

List parsing expressions can often become more compact. Generally, they indent and simplify the iteration type. for more work, a simple for statement may be easier to understand, and it will be easier to modify in the future.

Other iteration Environments

List parsing, in member testing, built-in map functions, and built-in functions such as sorted and zip calls also use the iteration protocol. When applied to a temporary file, the iterators that use the file object will automatically scan:

 

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.