I'd make the suggestion that closures are not very "Pythonic". Use objects instead:
class add_n_func: def __init__(self, n): self.n = n def __call__(self, x): return x+self.n return [add_n_func(n) for n in range(10)]
As the article demonstrates, using nested lambda's doesn't work the way you expect for closures. Using an object does.
edit: update. I found the presentation where guido talks about how he dislikes all the functional stuff, including lambda.
http://74.125.93.104/search?q=cache:2QztD1KncJgJ:www.python....
Just rubbing it in.
As I already wrote it would look "fs = [partial(add, i) for i in range(10)]" and it works as expected.
I'd make the suggestion that closures are not very "Pythonic". Use objects instead: