dynamic function names

Bram Stolk bram at nospam.sara.nl
Mon Apr 28 10:24:00 CEST 2003


Is it possible in Python to define functions with a dynamic name?

something like:

def make_func(funcname) :
  def funcname :
    print "This func is named", funcname


The code above fails due to foo being unknown,
however, when calling as make_func("foo"), the "foo" string
cannot be used as a funcname.

   Bram Stolk

 Bram Stolk, VR Specialist.
 SARA Academic Computing Services Amsterdam, PO Box 94613, 1090 GP  AMSTERDAM
 email: bram at sara.nl   Phone +31-20-5923059  Fax +31-20-6683167

 "I heard if you play the NT-4.0-CD backwards, you get a satanic message."
 "Thats nothing, if you play it forward, it installs NT-4.0"

More information about the Python-list mailing list