Interesting problem - can it be done

Mark Sass sassman at nucentrix.net
Thu Aug 9 07:59:58 CEST 2001


Hi all,
    I have a list of strings and the strings are functions that I want to
call on an object.  How do I call the functions without hardcoding the
function call?  Here is an example

funclist = ['func1()', 'func2()', 'func3()']
x = len(funclist)
y = 0
while y < x:
    value = testobj.funclist[y]
    y = y +1

This way I could grow the list of functions to be called without coding more
like the way I am doing it now. I would like to avoid doing the following:

value = testobj.func1()
value = testobj.func2()
value = testobj.func3()

Any help would be great.

Thanks,
    Mark Sass







More information about the Python-list mailing list