Skip to content

Instantly share code, notes, and snippets.

@luhn
Created March 31, 2019 23:27
import sys
import inspect
def wrap(func):
attach()
return func
def attach():
frame = sys._getframe(2)
info = inspect.getframeinfo(frame)
# Python 3.7: "@wrap"
# Python 3.8: "def a():"
print(info.code_context[0])
@wrap
def a():
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment