Steve Holden wrote:
There's always a way:

 >>> def test():
...   print "hello"
...
 >>> var = "test"
 >>> eval("%s()" % var)
hello

I'd go with locals() for the simple case of a name lookup:

Py> def test():
...   print "Hi there!"
...
Py> var = "test"
Py> locals()[var]()
Hi there!

Cheers,
Nick.

--
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---------------------------------------------------------------
            http://boredomandlaziness.skystorm.net
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to