annonymous functions -- how to

Jason Mobarak jason.mobarak at gmail.com
Wed May 4 23:46:44 EDT 2005


What's wrong with:

def blah():
  def _ (a, b, c):
    a = a + 2
    print "stmt 2"
    return a+b/c
  return doSomethingWith(_)

It's basically "anonymous", it just uses a name that you don't care
about. AFAIK, it can be immediately clobbered later if need be.
Otherwise, the function shouldn't be anonymous.




More information about the Python-list mailing list