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 f开发者_JS百科unctions 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?
I managed to find the solution.
i = __import__('baseapp.module')
m = getattr(i,'module')
return m.function_name
thanks for the help
精彩评论