PyMOTW: pyclbr

pyclbr can scan Python source to find classes and stand-alone functions. The information about class, method, and function names and line numbers is gathered using tokenize without importing the code.

Read more at pymotw.com: pyclbr