Recursively listing the contents of a package?

Terry Reedy tjreedy at udel.edu
Fri Dec 25 19:06:53 EST 2015


On 12/25/2015 6:01 PM, jeanbigboute at gmail.com wrote:
> 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.

IDLE has a module browser (called a Class Browser. , because that is 
what is started as), that displays a tree of module objects.  Just like 
a directory tree, nodes can be expanded or not.


-- 
Terry Jan Reedy




More information about the Python-list mailing list