how to get function names from the file

Kamilche klachemin at comcast.net
Wed Feb 15 17:58:32 EST 2006


The following will return a dictionary containing the names and
functions of all the public functions in the current module. If a
function starts with an underscore _, it is considered private and not
listed.

def _ListFunctions():
    import sys
    import types
    d = {}
    module = sys.modules[__name__]
    for key, value in module.__dict__.items():
        if type(value) is types.FunctionType:
            fnname = value.__name__
            if fnname[0] != '_':
                d[value.__name__] = value
    return d




More information about the Python-list mailing list