Re: list of all functions defined in the current module
In article <mailman.957.10 69416870.702.py thon-list@python.org >,
Gerhard Haring <gh@ghaering.de > wrote:
[color=blue]
> Fernando Rodriguez wrote:[color=green]
> > Hi,
> >
> > How can I get the list of all the functions defined in the current module?[/color]
>
> If you have
>
> def getfunctions(mo dule):
> 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(sy s.modules[__name__])
> to get a list of functions in the current module.
>
> Perhaps you could also use the builtin 'inspect' module for this task.[/color]
If you just want a list of a module's globals, what's wrong with
dir(modulename)
?
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.
Comment