Accessing function in a module by name

imho certo at comeno.it
Wed Jun 6 18:17:25 EDT 2007


Tobiah ha scritto:
> Is there a way to call function in an imported
> module having only the name?
> 
> 
> func_name = 'doit'
> 
> real_func = foo.some_magic(func_name)
> 
> #Now call it
> real_func(args)
> 
> 
> I'm trying to set up a function dispatcher for a
> SOAP server.
> 
> Thanks,
> 
> Tobiah
> 

What's wrong with real_func = getattr(foo, func_name) ? Maybe I 
misunderstood your question ?



More information about the Python-list mailing list