Function returns a function

James Stroud jstroud at
Tue Sep 6 22:59:19 CEST 2005


I want a "function factory" function in python. To do this I made a class like 
such (this is for Tkinter, in case your wondering):

class FunctionMaker:
  def __init__(self, avar, function, label)
    self.var = avar
    self.function = function
    self.label = label
  def __call__(self, e=None):

It seems that it would make more sense to make this a function and add it to 
the mixin I am writing. But I'm not quite sure how to do this without making 
lambdas, which seem a little messy and also look to be on the brink of 
deprecation (really not trying to start a lambda pro/con thread here).

Any ideas on how to do this with a regular function, or is the way I've done 
it the pythonic choice?


James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

More information about the Python-list mailing list