[Tutor] Querying a packages modules?
warpcat at gmail.com
Fri Nov 20 23:10:08 CET 2009
On Fri, Nov 20, 2009 at 12:28 PM, Kent Johnson <kent37 at tds.net> wrote:
> On Fri, Nov 20, 2009 at 3:05 PM, Dave Angel <davea at ieee.org> wrote:
> > Eric Pavey wrote:
> >> lol, in usual fashion, after I hack through it, while in the docs, I
> >> the 'fancy' solution:
> >> import pkgutil
> >> import myPackage
> >> modules = pkgutil.iter_modules(myPackage.__path__)
> >> for p in modules:
> >> print p
> >> moduleA
> >> moduleB
> > Thanks much for that. It's apparently in the code, but it's not in the
> > (Windows) help doc. Is that a doc bug?
> Seems to be. The pkgutil docs are quite sparse:
I'd seen a reference to that module online, looked in the docs, didn't see
much. But I imported it into my IDE anyway, which exposes all the methods
and classes, and I realized it did a lot more than the docs said. So I
opened the module itself and poked around until I found iter_modules() and
after some trial and error got it workin'
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor