Created
March 31, 2019 23:27
-
-
Save luhn/d1dac5eff4d6fd0018ae12eac48e94e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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