Using map()

Ian Kelly ian.g.kelly at gmail.com
Mon Nov 17 01:56:47 EST 2014


On Sun, Nov 16, 2014 at 4:22 PM, Terry Reedy <tjreedy at udel.edu> wrote:
> If pylint sees 'map(lambda ...: ', it would be appropriate to suggest using
> a comprehension or generator expression instead.  This avoids the unneeded
> creation and repeated call of a new function.

There's actually a separate warning for that: "map/filter on lambda
could be replaced by comprehension (deprecated-lambda)". I agree with
you, though.

On Sun, Nov 16, 2014 at 6:31 PM, Dan Stromberg <drsalists at gmail.com> wrote:
> BTW, I believe in Python 2.x map is like a list comprehension, but in
> 3.x map is like a generator expression.

Yes, just like other functions such as range or dict.items that return
lists in Python 2 but something more light-weight in Python 3.



More information about the Python-list mailing list