how to get function names from the file

Petr Jakes mcbooczech at gmail.com
Wed Feb 15 17:03:42 EST 2006


I have got names of functions stored in the file. For the simplicity
expect one row only with two function names: printFoo, printFOO
In my code I would like to define functions and then to read function
names from the file, so the functions can be executed in the order the
function names are stored in a file.

While trying to read the names from the file I am getting always
"strings" and I am not able to execute them.

I would like to write my code so it will look something like:

def printFoo():
    print "foo"

def printFOO():
    print "FOO"

# here I would like to read the file with the function names sequences
# and to create tuple which will contain the function names.
# After that I would like to call functions from the tuple:

functions=(printFoo, printFOO)
for function in functions:
   function()

Thanks for your postings
Petr Jakes




More information about the Python-list mailing list