Best way to enumerate classes in a module
Terry Reedy
tjreedy at udel.edu
Wed Jun 24 13:07:36 EDT 2009
Дамјан Георгиевски wrote:
> I need to programmaticaly enumerate all the classes in a given module.
> Currently I'm using dir(module) but the Notice on the documentation page
> [1] says "dir() is supplied primarily as a convenience for use at an
> interactive prompt" so that kind of scares me.
That notice primarily refers to the fact that the special names (of
__xxx__ form) returned are implementation and version dependent, and may
not be complete in the sense that dir(ob) may not return __xyz__ even
though ob.__xyz__ exists and can be retrieved.
If you are only interested in regular-name attribute of ob, let your
fear fly away.
More information about the Python-list
mailing list