programmatically calling a function

Reinhold Birkenfeld reinhold-birkenfeld-nospam at wolke7.net
Sat Mar 5 09:39:24 EST 2005


Doug Schwarz wrote:

> Dave,
> 
> I think eval might be what you're looking for:
> 
> f = eval('len')
> length = f([1,2,3])

But only if the string given to eval is checked thorougly for allowed
contents. Better use getattr.

Reinhold



More information about the Python-list mailing list