Python map with two or more arguments


Built-in Python function map() is best way to iterate and generate a new list from given list. Usually we using one arguments when passing objects into function inside map(), eg:

1
map(show_records, list_records)

At this example, x from list_records will passed into show_records(x). But, how to passing multiple arguments into map() ?
Basically, it’s easy with lambda():

1
map(lambda x: show_records(x, some_new_params), list_records)

And you can receive some_new_params in show_records(x, some_new_params) 🙂


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.