[Tutor] Introspection (modules and functions)
ewald.ertl at hartter.com
Wed Nov 23 16:39:57 CET 2005
I quick solution for a name module could be:
>>> import os
>>> for d in os.__dict__:
... a="os." + d
... if callable( eval(a) ):
... print "Callable %s" % ( eval(a))
but there should also be a recipe on activestate for that problem.
I think I've red something in the Python Cookbook
Negroup - wrote:
> My application hosts a module A that contains only a (variable) number
> of functions. In another part of this application I need to know which
> functions are defined inside module A. Initially I thought to use
> __dict__, but along with the functions of module A are listed all the
> builtins too.
> How is possible to obtain this information without defining
> return_all_functions() (see below)?
> Actually module A is something like:
> def f1():
> def f2():
> # def ....
> # def ...
> def return_all_functions():
> t = (f1, f2, ....)
> return t
> Tutor maillist - Tutor at python.org
More information about the Tutor