On Wed, 24 Oct 2007 15:09:02 +0000, mrstephengross wrote: >> import module >> from inspect import getmembers, isclass >> classes = getmembers(module, isclass) > > Ok, this makes sense. How can I do it inside the .py file I'm working > on? That is, consider this: > > class A: > pass > class B: > pass > import inspect > print inspect.getmembers(<this file>, inspect.isclass) # how can I > express <this file> ?
If you want the objects from the current module you can simply look at the `globals()` dictionary. from inspect import isclass from itertools import ifilter classes = set(ifilter(isclass, globals().itervalues())) Ciao, Marc 'BlackJack' Rintsch -- http://mail.python.org/mailman/listinfo/python-list