Skip to content

Instantly share code, notes, and snippets.

@joonahn
Created February 27, 2018 08:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joonahn/01456a23529c9ff768081d83699e77b8 to your computer and use it in GitHub Desktop.
Save joonahn/01456a23529c9ff768081d83699e77b8 to your computer and use it in GitHub Desktop.
import inspect
def get_caller_source_lines(cls, num_of_prev_functions=1):
# num_of_prev_functions
frame = inspect.stack()[1 + num_of_prev_functions]
_, linenum, _, _, _ = inspect.getframeinfo(frame)
return linenum
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment