In the previous lesson, you covered how to use the
map() function in Python in order to apply a function to all of the elements of an iterable and output an iterator of items that are the result of that function being called on the items in the first iterator.
In this lesson, you’ll see how the
map() function relates to list comprehensions and generator expressions. You’ll learn that using them is (arguably) more Pythonic than relying on plain
breaves on March 29, 2020
I think map() is still useful because in some cases you need a list to be returned, for example in a pandas dataframe, replacing one column of strings by applying a function that’s more than a one-liner.
Also, I like to write readable python code, so that others can use and maintain my software. I’ve had my python code translated to a dot net framework, and objective-c for iOS. The person doing that translation knows xcode well, but not python at all. Because my code was readable to her, she could do that work independently.