Python, Lambda, Closures

5 Apr 2011

A very interesting post from AndrĂ© Pang about some issues he came across with lamdas and closures in Python. Well, interesting to me because I’m playing with Lisp and Python at the moment.

Some links from his blog, in case the original post ever disappears:

A nice snippet of code to remind me of the issues:

def callback(msg):
    print msg
for m in ('do', 're', 'mi'):
    # funcList.append(lambda: callback(m))
    funcList.append(lambda m=m: callback(m))
for f in funcList:
comments powered by Disqus

  « Previous: Next: »