[Tutor] Querying a packages modules?

Eric Pavey warpcat at gmail.com
Fri Nov 20 03:31:27 CET 2009


Say I have this package layout

   - \myPackage
   - __init__.py
      - moduleA.py
      - moduleB.py

Is there a way (and I'm sure there is...) to query, for a given package
level, which modules live under it?
I thought I could do it like so:

import myPackage
goodQualityInfo = dir(myPackage)

Thinking that he modules are just attributes of the package.  And while this
prints some nice stuff, it has no knowledge of moduleA & B.  I feel like
missing\forgetting some fundamental command or something ;)

If you're wondering, I'm authoring a tool that will take whatever modules
are placed in the package (authored to a certain standard) and execute them
based on a passed-in dataset to each.  But first I've got to get that list
of modules.  I've thought of some hacky-ways in my head, but I'd like to see
if there is something a bit more elegant...

thanks!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20091119/c493c981/attachment.htm>


More information about the Tutor mailing list