Recursively listing the contents of a package?

jeanbigboute at gmail.com jeanbigboute at gmail.com
Fri Dec 25 18:01:51 EST 2015


As an occasional Python user, I'd like to be able to get for myself a high-level overview of a package's capabilities.  I can do this after a fashion interactively in IPython using tab completes.  

e.g.
import numpy as np
np.<tab> ---> Big list of capabilities, highlight one item
np.array<tab> --> Nothing in the dropdown
np.random.<tab> --> ~~75 items in dropdown
np.random.test<tab> --> 3 items in dropdown

For big packages like numpy, matplotlib, etc., this is slow.  

My web searches have resulted in pointers to dir, help, inspect, getattr,  hasattr, pydoc, and so on.  As far as I can tell, these will give you information if you know what you are seeking.  99% of the time, I don't know what I don't know.

Is there a way to determine if a method/function/correct term has items underneath it?

If such a thing exists, I think I could write the code to descend through a package's functions/methods, make a list of nodes and edges, send it to networkx, and create a graph of a package's capabilities.

Thanks,

JBB



More information about the Python-list mailing list