loading...

re: 10 Awesome Pythonic One-Liners Explained VIEW POST

FULL DISCUSSION
 
  1. List mapping

Best to use list comprehensions instead of map in most cases. For your example:

l = [int(x) for x in ['1', '2', '3']]
 

I agree, this increases readability even more! Thank you. Is there any other benefit in using list comprehensions instead of the (specially made for this purpose) map() function?

 

map returns a map object that you then turn into a list. Readability. There are other comprehensions that follow naturally from list comprehensions to generate, for example, dicts, sets and iterators.

Code of Conduct Report abuse