Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80960

Re: Using map()

References <3b3e245f-c377-4543-b9eb-186e5087103a@lists.xtsubasa.org> <m4bbjd$76j$1@ger.gmane.org>
From Ian Kelly <ian.g.kelly@gmail.com>
Date 2014-11-16 23:56 -0700
Subject Re: Using map()
Newsgroups comp.lang.python
Message-ID <mailman.15946.1416207457.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Sun, Nov 16, 2014 at 4:22 PM, Terry Reedy <tjreedy@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@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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Using map() Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-16 23:56 -0700

csiph-web