On Tue, Mar 25, 2014 at 8:43 AM, Mark H Harris <harrismh...@gmail.com> wrote: >> adders[n] = (lambda b: lambda a: b + a)(n) > > Now, here is where I talk about confusion; explaining why the first > lambda above does not work because of scope and closure, and then even > worse, explaining why the second "double" lambda works in the lower example!
Easy fix. Use the "explicit capture" notation: adders[n] = lambda a, n=n: a+n And there you are, out of your difficulty at once! ChrisA -- https://mail.python.org/mailman/listinfo/python-list