Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Python Programming Language

Accessing function in a module by name


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

--
Posted via a free Usenet account from http://www.teranews.com

Tobiah ha scritto:

What's wrong with real_func = getattr(foo, func_name) ? Maybe I
misunderstood your question ?
On Jun 7, 8:13 am, Tobiah <t@tobiah.org> wrote:

> 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)

Presuming 'foo' is the name of the module:

real_func = getattr(foo, func_name)

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

Nothing, it just didn't exist in my mind until now.

Thanks

--
Posted via a free Usenet account from http://www.teranews.com

Tobiah wrote:
> Is there a way to call function in an imported
> module having only the name?
...
> I'm trying to set up a function dispatcher for a
> SOAP server.

    Bad idea.  This exposes all the functions of the
module to calls from the outside world.  Big security hole.

    In any case, SOAP servers should have a separate object for
each connection, or the thing will mess up if two requests
are made at the same time.

    See

        http://www.ibm.com/developerworks/library/ws-pyth5/

                                John Nagle

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc