Python's program structure [2], class/class, built-in class map

Source: Internet
Author: User

built-in class map/built-in type map

About built-in classes

Map is a built-in class that can return a map of obj. The first parameter of map is an executable function, and subsequent parameters are iterated objects, and map iterates over subsequent parameters and passes them to the executable function, saving the result.

1 def Foo (A, B, c): 2     return a+b+C3print(list (map (foo, range (4), Range (4), Range (4)))

The above code outputs the result as

[0, 3, 6, 9]

Note: in Python2, because map is still a function, the result returned is not obj but a list, which can be printed directly, and the map function supports None as the first parameter, and returns a result similar to the zip effect. However, this feature has been canceled in Python3.

For a map of Python2, refer to here.

Related reading

1. About the built-in class

Python's program structure [2], class/class, built-in class map

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.