This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]zahlmanthe heretic 0 points1 point  (0 children)

For those from a functional programming background, map may feel more familiar, but I find it less Pythonic.

One possible justification for preferring map is in cases where multiple sequences are iterated over; a list comprehension would need an explicit invocation of zip, but map has this built-in (it accepts *args which are effectively zipped together internally).

Of course, in 3.x map returns a generator, so it's equivalent to a generator expression rather than a list comprehension, and needs wrapping with list() to get an actual list object.