list of all functions defined in the current module

David Eppstein eppstein at
Fri Nov 21 18:26:41 CET 2003

In article <mailman.957.1069416870.702.python-list at>,
 Gerhard Haring <gh at> 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:
>              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.

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            
Univ. of California, Irvine, School of Information & Computer Science

More information about the Python-list mailing list