In article <[EMAIL PROTECTED]>,
 Dave Ekhaus <[EMAIL PROTECTED]> wrote:

> hi
> 
>       i'd like to call a python function programmatically - when all i have 
> is the functions name as a string.  i.e.
> 
>       
> fnames = ['foo', 'bar']
> 
> for func in fnames:
> 
>       #
>       # how do i call function 'func' when all i have is the name of the 
> function ???
>       #
>       
> 
> 
> def foo():
>       
>       print 'foo'
> 
> def bar():
> 
>       print 'bar'
> 
> 
>       i'd really appreciate any help the 'group' has to offer.
> 
> 
> thanks
> dave


Dave,

I think eval might be what you're looking for:

f = eval('len')
length = f([1,2,3])


By the way, are you the Dave Ekhaus I used to work with at Kodak?

-- 
Doug Schwarz
dmschwarz&urgrad,rochester,edu
Make obvious changes to get real email address.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to