You may have found inspiration in this recipe:
A function that displays the human-readable version of Python AST.
Or use compilerin conjunction with inspect(which, of course, uses the source):
>>> import compiler, inspect
>>> import re
>>> compiler.parse(inspect.getsource(re))
Module('Support for regular expressions (RE). \n\nThis module provides ...
source
share