[Tutor] Trying To Debug Code That Runs Arbitrary Function

Homme, James james.homme at highmark.com
Thu Dec 2 15:35:15 CET 2010

If you can get away with not telling me the answer, but pointing me to where to look for the answer, I'd be grateful.

In my Python learning, I am just now starting to understand how to make classes and extend them, so I have a very long way to go.

I wrote this code because I wanted to avoid lots of if statements and having to maintain a bunch of code like that. Eventually, my idea is to read in strings from a file, look one up, and use it to execute a function. So I created the following code. But nothing gets printed to the screen. How do I go about figuring out why this isn't happening? Here's the code.

myfuncs = [ "func1",
                "func2" ]

def func1():
  print "func 1"

def func2():
  print "func 2"

eval (myfuncs[0])

raw_input("Press enter to quit")


Jim Homme,
Usability Services,
Phone: 412-544-1810. Skype: jim.homme
Internal recipients,  Read my accessibility blog<http://mysites.highmark.com/personal/lidikki/Blog/default.aspx>. Discuss accessibility here<http://collaborate.highmark.com/COP/technical/accessibility/default.aspx>. Accessibility Wiki: Breaking news and accessibility advice<http://collaborate.highmark.com/COP/technical/accessibility/Accessibility%20Wiki/Forms/AllPages.aspx>

This e-mail and any attachments to it are confidential and are intended solely for use of the individual or entity to whom they are addressed. If you have received this e-mail in error, please notify the sender immediately and then delete it. If you are not the intended recipient, you must not keep, use, disclose, copy or distribute this e-mail without the author's prior permission. The views expressed in this e-mail message do not necessarily represent the views of Highmark Inc., its subsidiaries, or affiliates.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20101202/d818ccc7/attachment.html>

More information about the Tutor mailing list