[Tutor] Dynamic Function Calls
Megan Land
mland at us.ibm.com
Thu Aug 13 21:30:41 CEST 2009
Hi,
I'm trying to call a function from a dictionary. I did some googling and
from what I can tell my code should work, but doesn't. Here's an example:
def myFunc(self, inputList):
dict={0: func0, 1: func1, 2:func2}
for element in inputList:
dict[element]()
When I go to run this I get an error saying func0 is not defined. Does
anyone have any ideas as to why this won't work? I'm using Python 2.6 if
that makes any difference.
Thanks!
Megan Land
FVT Blade EMET Test Engineer
mland at us.ibm.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090813/5ba85336/attachment.htm>
More information about the Tutor
mailing list