Functions 'knowing' other functions in a module
gyromagnetic at excite.com
Wed Jan 22 19:16:13 CET 2003
I have an application in which it would be useful for functions within
the module in which they reside to be able to list the other functions
(and their arguments) in the module.
Currently, I am doing the following:
me = __import__('mymod')
efuncs = 
funcs = inspect.getmembers(me,inspect.isfunction)
for fname,func in funcs:
fcode = func.func_code
if not fname.startswith('_'):
num_args = fcode.co_argcount
efuncs = _enum_functions()
This approach seems very kludgy, especially the __import__('mymod')
line. Is it necessary to 'self import' the module to carry out this
task? Any suggestions for a better approach? I'm sure that I'm missing
Right now, it does not make sense to move the functions into a class, so
approaches of this nature aren't currently feasible.
On an unrelated note, is it possible to use string interpolation in doc
strings? I tried a few different approaches to this, none of which
worked. If this is not possible, what is the reason?
More information about the Python-list