lambda in list comprehension acting funny

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Jul 12 22:20:05 EDT 2012


On Thu, 12 Jul 2012 18:23:10 +0100, Rotwang wrote:

> I don't think anyone has suggested this yet:
> 
> funcs = [(lambda i: lambda x: x**i)(i) for i in range(5)]

Oooh, nice! A factory function solution. Excellent!



-- 
Steven



More information about the Python-list mailing list