How to find out which functions exist?
Marc 'BlackJack' Rintsch
bj_666 at gmx.net
Wed Oct 24 11:41:03 EDT 2007
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
More information about the Python-list
mailing list