All names in the current module
Ian Clark
iclark at mail.ewu.edu
Wed Aug 15 15:01:52 EDT 2007
Torsten Bronger wrote:
> Hallöchen!
>
> How can I get a list with all classes defined in the current module?
> Thank you!
>
> Tschö,
> Torsten.
>
Assuming you want to see all classes in the re module:
>>> import re
>>> help(re) #best way
>>>
>>> def isclass(cls):
... try:
... return issubclass(cls, cls)
... except TypeError:
... pass
... return False
...
>>> [cls for cls in dir(re) if isclass(getattr(re, cls))]
['Scanner', '_pattern_type', 'error']
Ian
More information about the Python-list
mailing list