Using map()

Terry Reedy tjreedy at udel.edu
Sun Nov 16 18:22:09 EST 2014


On 11/16/2014 8:01 AM, Pavel Volkov wrote:
> I checked my modules with pylint and saw the following warning:
>
> W: 25,29: Used builtin function 'map' (bad-builtin)
>
> Why is the use of map() discouraged?
> It' such a useful thing.

I consider that to be a bug in pylint.  It misstates a careless 'bad' 
opinion as a fact.

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.  If it sees 
'map(<identifier>,', I think it should say nothing.

-- 
Terry Jan Reedy




More information about the Python-list mailing list