import sys
import traceback

def dump_stack(file=sys.stdout):
    print(
        *traceback.StackSummary.extract(
            traceback.walk_stack(sys._getframe(1)), capture_locals=True
        ).format(), sep='\n', file=file
    )

def foo(b):
    c = b + 1
    dump_stack()

a = 1
foo(a)