En Mon, 17 Dec 2007 14:20:38 -0300, Matias Surdi <[EMAIL PROTECTED]> escribió:
> How can I get all the clasess inside a package (including it > subpackages) ? > > for example, I have a package with classes A and B and with a subpackage > wichs has class C. > > How can I get a list (and a path) of the classes that exists under the > root package ? If the package does not import its modules or subpackages in __init__.py, you'll have to inspect the __path__ attribute and enumerate .py files. Then, try to load them and find all classes. Warning: There is no way to tell if a certain module is intended to be imported at all or not (might be a test module, an unimplemented feature, a leftover from previous versions, a script intended to be run from the command line...) You can use the inspect standard module (mainly getmembers() and isclass()) to find all classes; remember to filter by the class __module__ attribute (else you'll get imported classes too). -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list