Skip to content

Instantly share code, notes, and snippets.

@akscram
Created May 7, 2014 09:03
Show Gist options
  • Save akscram/7d7adc475bede56fe612 to your computer and use it in GitHub Desktop.
Save akscram/7d7adc475bede56fe612 to your computer and use it in GitHub Desktop.
import inspect
def print_stack():
print(" -> ".join(
"{0}:{1}".format(stack[1], stack[2])
for stack in inspect.stack()
))
print_stack()
def some():
print_stack()
def k():
some()
k()
@maximkulkin
Copy link

import inspect

def print_line():
    stack = inspect.stack()[1]
    print("{0}:{1}".format(stack[1], stack[2]))

print_line()

def some():
    print_line()

def k():
    some()

k()

@maximkulkin
Copy link

foo.py:7
foo.py:10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment