[Somewhat Off Topic] AI Contest
Doug Fort
dougfort at dougfort.net
Thu Aug 9 06:55:37 EDT 2001
Mike Clarkson wrote:
> 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
>
>
>
>
>
you can say:
for func in funclist:
eval(func)
--
Doug Fort <dougfort at dougfort.net>
http://www.dougfort.net
______________________________________________________________________
Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com
With Seven Servers In California And Texas - The Worlds Uncensored News Source
More information about the Python-list
mailing list