Skip to content

Instantly share code, notes, and snippets.

@bhpayne
Last active June 10, 2019 18:13
Show Gist options
  • Save bhpayne/ec2f9dffd1c8b9c98f7ec80bf7b01621 to your computer and use it in GitHub Desktop.
Save bhpayne/ec2f9dffd1c8b9c98f7ec80bf7b01621 to your computer and use it in GitHub Desktop.
from inspect import stack, currentframe, getframeinfo # file name and line number
def prntln(*args):
"""
https://stackoverflow.com/questions/24438976/python-debugging-get-filename-and-line-number-from-which-a-function-is-called
"""
caller = getframeinfo(stack()[1][0])
print(caller.filename, caller.lineno, args)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment