Here's your hint... to execute a Python function, it must be followed by
parentheses.... otherwise you are just referring to the function object.

HTH,

Vern

On Thu, Dec 2, 2010 at 9:35 AM, Homme, James <[email protected]>wrote:

>  Hi,
>
> 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")
>
>
>
> Thanks.
>
>
>
> Jim
>
> 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.
>
> _______________________________________________
> Tutor maillist  -  [email protected]
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>
>


-- 
Vern Ceder
[email protected], [email protected]
The Quick Python Book, 2nd Ed - http://bit.ly/bRsWDW
_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to