April 2, 2020

Print source code of a function

When we want to see source code of the function called "func" in "foo" library.

import inspect
import foo

print inspect.getsource(foo.func)