def foo(x): return y + z import inspect frame = inspect.currentframe() print inspect.getsource(frame)