Skip to content

Instantly share code, notes, and snippets.

@semeltheone
Created May 8, 2013 05:16
Show Gist options
  • Save semeltheone/5538373 to your computer and use it in GitHub Desktop.
Save semeltheone/5538373 to your computer and use it in GitHub Desktop.
Getting the source code and doc comments of a given python function. See http://docs.python.org/2/library/inspect.html for more info about introspection.
from inspect import *
def testFunction(unusedParameter):
"""Test introspection in python.
:param unusedParameter: A unused parameter
"""
a = 'test'
b = a
c = b
return c
print getsource(testFunction)
print getdoc(testFunction)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment