I'm working on a documentation (personal) for nested matplotlib (MPL) library, which differs from MPL own provided, by interested submodule packages. I'm writing Python script which I hope will automate document generation from future MPL releases.
I selected interested submodules/packages and want to list their main classes from which I'll generate list and process it with pydoc
.
The problem is that I can't find a way to instruct Python to load a submodule from a string. Here is an example of what I tried:
import matplotlib.text as text
x = dir(text)
i = __import__('matplotlib.text')
y = dir(i)
j = __import__('matplotlib')
z = dir(j)
And here is a 3-way comparison of above lists through pprint:
I don't understand what's loaded in y
object - it's base matplotlib
plus something else, but it lacks information that I wanted and that is main classes from matplotlib.text
package. It's the top blue coloured part on screenshot (x
list).
__import__(str)
rather than the standardimport
statemetn? – Gearhartimport
statement. Here's one example of use: djangosnippets.org/snippets/3048 – Transparency