How to: get list of modules in a package

Dan Perl danperl at rogers.com
Tue Oct 12 05:49:30 CEST 2004


Is there a direct way to get a list of all the modules in a package, other 
than using an os.listdir() for the directory of the package?

To be more specific, I would like to inspect every module in a package and 
check if it contains the definition of a certain class.  At the same time, I 
would like to be able to add modules to this package in a dynamic way, so 
__init__.py would not be of much help because I do not want to change it for 
every new module.

Thanks,

Dan 





More information about the Python-list mailing list