def decompile_module(mod):
    return '\n\n'.join(decompile_function(m) if isfunction(m) else 
        decompile_class(m) if isclass(m) else '# UNKNOWN: ' + repr((n, m)) for
        n, m in inspect.getmembers(mod) if inspect.getmodule(m) is mod)
Recovering .pyc file from python interpreter