How to find out which functions exist?

Diez B. Roggisch deets at
Wed Oct 24 17:28:26 CEST 2007

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> ?

Then you can use globals(), like this:

classes = [v for v in globals().values() if isclass(v)]


More information about the Python-list mailing list