"eval" is not necessary in this case.
If you have a tuple with function names such as this: x=(printFoo,
printFOO)
you can execute them this way:
>>> for f in x:
f()
--
http://mail.python.org/mailman/listinfo/python-list
Petr Jakes wrote:
> 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
Petr Jakes wrote:
> 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
"Petr Jakes" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>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
The following will return a dictionary containing the names and
functions of all the public functions in the current module. If a
function starts with an underscore _, it is considered private and not
listed.
def _ListFunctions():
import sys
import types
d = {}
module = sys.modules
Petr Jakes wrote:
> 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
Try the following:
def printFoo():
print "Foo"
def printFOO():
print "FOO"
functions = ("printFoo", "printFOO")# list or tuple of strings from
file, or wherever
for function in functions:
call = function + "()"
eval(call)
--
http://mail.python.org/mailman/listinfo/python-li