Finding all classes in a module

Mark McEahern marklists at
Fri Aug 9 21:11:22 CEST 2002

> The replies you got so far only seem to work for old-style classes:


Good point.  Here's another approach:

  class foo:pass
  class bar(object):pass


  >>> import junk
  >>> import inspect
  >>> inspect.getmembers(junk, inspect.isclass)
  [('bar', <class ''>), ('foo', <class at 0x10102d28>)]

and so.

// mark

More information about the Python-list mailing list