guide to introspecting python?

Mark Harrison mh at dreadnok.pixar.com
Tue Aug 3 19:08:36 EDT 2004


What's a good document to read in order to understand some
of python's introspective functions?

I'm trying to recurse through a module and print information
about its contents.  dir() does something similar to what
I have in mind, but it's documented to be more for human
interaction than definitive programmatic correctness,
so I'd like to call or look at whatever it's using.

This bit of code never finishes because dir(something)
and dir(something.__call__) return the same thing.

def rdir(item, v=""):
    print "%s%s"%(v,item)
    for i in dir(item):
        rdir(i, v+"    ")

import os
rdir(os)


Any help/pointers appreciated!

Thanks,
Mark

PS, you will probably recognize this as my attempt to
generate programatically the module/function/parameter
index I previously asked about...

-- 
Mark Harrison
Pixar Animation Studios



More information about the Python-list mailing list