Skip to content

Instantly share code, notes, and snippets.

@mamaj
Created December 17, 2021 01:42
Show Gist options
  • Save mamaj/87fe50ceae7367ca1b431c5edebae4a5 to your computer and use it in GitHub Desktop.
Save mamaj/87fe50ceae7367ca1b431c5edebae4a5 to your computer and use it in GitHub Desktop.
python trace
import sys
def tracer(frame, event, arg):
print(f'{frame = }')
print(f'{event = }')
print(f'{arg = }')
print()
# if you enter any function, still use the same trace function.
if event == 'call':
return tracer
sys.settrace(tracer)
def inc(i):
return i
inc(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment