F
Fernando Rodriguez
Hi,
How can I get the list of all the functions defined in the current module?
How can I get the list of all the functions defined in the current module?
Fernando said:Hi,
How can I get the list of all the functions defined in the current module?
Fernando said:Hi,
How can I get the list of all the functions defined in the current module?
Gerhard Haring said:Fernando said:Hi,
How can I get the list of all the functions defined in the current module?
If you have
def getfunctions(module):
import types
l = []
for key, value in module.__dict__.items():
if type(value) is FunctionType:
l.append(value)
return l
Then you can call this function with getfunctions(sys.modules[__name__])
to get a list of functions in the current module.
Perhaps you could also use the builtin 'inspect' module for this task.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.