views:

23

answers:

1

I have a list of functions as:

FUNCS=[{'someattr':'somedetail', 'func':baseapp.module.function_name}, {...}, ...]

Unfortunately it doesnt work if i try calling the func with

FUNCS[0]['func']

I get the error

Tried function_name in module baseapp.module Error was: 'module' object has no attribute 'function_name'

I presume there must be something i'm missing with how python finds functions because the following does work:

   In [11]: def localfunc():
   ....:     print 'hi there'
   ....:     return

   In [13]: f=[{'func':localfunc}]

   In [16]: f[0]['func']()

   hi there

What am i missing?

A: 

I managed to find the solution.

i = __import__('baseapp.module')
m = getattr(i,'module')
return m.function_name

thanks for the help

Duncan