list of all functions defined in the current module
eppstein at ics.uci.edu
Fri Nov 21 18:26:41 CET 2003
In article <mailman.957.1069416870.702.python-list at python.org>,
Gerhard Haring <gh at ghaering.de> wrote:
> Fernando Rodriguez wrote:
> > 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:
> 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.
If you just want a list of a module's globals, what's wrong with
Of course it will tell you about globals that are not functions (e.g.
classes) but maybe that's what the original poster wanted anyway.
David Eppstein http://www.ics.uci.edu/~eppstein/
Univ. of California, Irvine, School of Information & Computer Science
More information about the Python-list