get list of callable methods

John Hunter jdhunter at ace.bsd.uchicago.edu
Thu Oct 14 19:46:15 CEST 2004


What is the best way to get a list of all functions actually defined
in a module, ignoring those functions that the module may have
imported but not defined?

The following gets a list of all the callables, but includes functions
that some.module imports

funcs = []
for o in dir(some.module):
     if o.startswith('_'): continue
     p = getattr(some.module, o)
     if not callable(p): continue
     funcs.append(p)

 


JDH



More information about the Python-list mailing list