RE: Python: Making A Program Run A Function That Is Not Hard Coded

  • From: "Homme, James" <james.homme@xxxxxxxxxxxx>
  • To: "programmingblind@xxxxxxxxxxxxx" <programmingblind@xxxxxxxxxxxxx>
  • Date: Thu, 2 Dec 2010 08:00:54 -0500

Hi Johannes,
Do you mean something like this:
if s in list:
eval(s)

Jim

Jim Homme,
Usability Services,
Phone: 412-544-1810. Skype: jim.homme
Internal recipients,  Read my accessibility blog. Discuss accessibility here. 
Accessibility Wiki: Breaking news and accessibility advice


-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Johannes Grib
Sent: Thursday, December 02, 2010 7:59 AM
To: programmingblind@xxxxxxxxxxxxx
Subject: RE: Python: Making A Program Run A Function That Is Not Hard Coded

Have a function with the same name as your list entry and perform an 
eval(string_name)
HTH
 

-----Original Message-----
From: programmingblind-bounce@xxxxxxxxxxxxx 
[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Homme, James
Sent: Thursday, December 02, 2010 2:55
To: programmingblind@xxxxxxxxxxxxx
Subject: Python: Making A Program Run A Function That Is Not Hard Coded

Hi,

I'm trying to be clear about this question, but maybe this can't be done. 

 

Let's say that you have a list that contains twenty strings. 

Your program reads in a string from a file.

The string from the file matches one of the strings in your list.

You want to perform a function that may be associated with that string.

You don't want to write twenty if statements to see if the string in the file 
matches and perform the function associated with that string.

You want to somehow get the program to see the string and the function 
associated with it and just perform it.

 

Is this possible?

 

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.

__________
View the list's information and change your settings at 
//www.freelists.org/list/programmingblind

__________
View the list's information and change your settings at
//www.freelists.org/list/programmingblind

Other related posts: