[Tutor] Trying To Debug Code That Runs Arbitrary Function

Alan Gauld alan.gauld at btinternet.com
Thu Dec 2 18:57:15 CET 2010


"Homme, James" <james.homme at highmark.com> wrote

> 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.

OK, Don't use eval or exec they have secuity issues - especially if 
reading the
strings from a file!

> idea is to read in strings from a file, look one up,
> and use it to execute a function.

Functions are objects sop can be stored as data.
Dictionariers can associate strings with arbitrary data - including 
functions.

Is that enough of a hint? :-)

If not, try reading the OOP topic in my tutorial, under the section 
heading
"Collections of Objects" where I discuss the related scenario of 
managing
collections of objects with arbitrary (or user assigned) names/IDs.

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list