Python list functions for imported module

To list the functions available for the imported module, use inspect.getmembers():

$ python
>>> import inspect
>>> import pprint
>>> import django
>>> pprint.pprint(inspect.getmembers(django))
[('VERSION', (1, 8, 4, 'final', 0)),
 ('__builtins__', { '...' }
 ('__doc__', None),
 ('__file__', '/Library/Python/2.7/site-packages/django/__init__.pyc'),
 ('__name__', 'django'),
 ('__package__', 'django'),
 ('__path__', ['/Library/Python/2.7/site-packages/django']),
 ('__version__', '1.8.3'),
 ('get_version', <function get_version at 0x10bc52320>),
 ('setup', <function setup at 0x10bc57500>),
  <module 'django.utils' from '/Library/Python/2.7/site-packages/django/utils/__init__.pyc'>)]

Alternatively, use dir():

import pprint
import django
>>> pprint.pprint(dir(django))
This post is available on GitHub.
Posted .


Leave a Reply