"David Rasmussen" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > If I have a string that contains the name of a function, can I call it? > As in: > > def someFunction(): > print "Hello" > > s = "someFunction" > s() # I know this is wrong, but you get the idea... > > /David
Lookup the function in the vars() dictionary. >>> def fn(x): ... return x*x ... >>> vars()['fn'] <function fn at 0x009D67B0> >>> vars()['fn'](100) 10000 -- Paul -- http://mail.python.org/mailman/listinfo/python-list