Functional Programming in Python: The "map()" Function

► Write better & cleaner code using Python’s advanced features

In this Python tutorial you’ll discover further basics of functional programming, namely how to use the “map()” function to transform data structures.

We’ll take an example data set represented using an immutable data structure from the previous videos in this series, and then we’ll create a “transformed” version of the same data using Python’s built-in map function.

“map()” is one of the functional programming primitives or building blocks available in Python and it’s useful in a number of contexts.

Later in the video you’ll also see how the map function relates to list comprehensions and generator expressions and how using them is (arguably) more Pythonic that relying on plain “map()” calls.

This video is part of a series of Python functional programming tutorials that I’m recording so stay tuned for the next instalment.

Be sure to check out these associated articles and tutorials if you want to dive deeper into the subject:

* Immutable Data Structures in Python:
* List comprehensions:

FREE COURSE – “5 Thoughts on Mastering Python”


* * *

► Python Developer MUGS, T-SHIRTS & MORE:

► PythonistaCafe – A peer-to-peer learning community for Python developers:

FREE Python Coding Tutorials & News:
» Python Tutorials:
» Python News on Twitter:
» Weekly Tips for Pythonistas:
» Subscribe to this channel:


Xem thêm bài viết khác:


  1. You really ramble on compared to some of the other teachers .

  2. it would be nice to have the list of scientists to copy/paste from to follow along

  3. In functional programming, if you keep making copies of past data when you make a transformation, how do you keep track of manage new variable names so you aren't having a ton of new variables?

  4. names_of_nobel_prize_winners = list(map(lambda x: getattr(x,'name'), filter(lambda x: x.nobel == True, scientists)))
    names_of_nobel_prize_winners = [x for x in map(lambda x: getattr(x,'name'), filter(lambda x: x.nobel == True, scientists))]

  5. Nice video. I had a couple of “AHA!” Moments during it. Thanks for the insight.

  6. Dan, in a daily basis and regarding to performance, what is the best choice? using list comprehensions vs map function?

  7. Hi. Nice work. However I think your tutorial here doesn't do justice to the map function, because once you introduce more than 1 iterables that's where the power of map changes in reference to list comprehensions / generators.


    tuple(map(lambda: x,y: x*y, [1,2,3], [1,2,3])) = (1, 4, 9)

    How would I do this using a list comprehension / generator expression ?

  8. U r amazing man…need more advanced tutorials using python…

  9. Excellent and concise delivery. Thanks for staying up after a long day – much appreciated

  10. Hello Dan, I've heard that you pronounce word "tuple" as tOOple not a tAple as I always thought. Is it a correct way to pronounce it?

  11. Nice vídeo! Perhaps it would be cool showing what happens when passed more than one iterable.

  12. Dan please tell me how you changed your cursor to this round ? I was looking for it but didn’t found

Leave a Reply

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