Skip to content

Instantly share code, notes, and snippets.

@codeslord
Created November 13, 2018 11:32
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 codeslord/9405fb4e81fa9b40bd102e5e0597199c to your computer and use it in GitHub Desktop.
Save codeslord/9405fb4e81fa9b40bd102e5e0597199c to your computer and use it in GitHub Desktop.
import sys
def tracefunc(frame, event, arg, indent=[0]):
if event == "call":
indent[0] += 2
print("-" * indent[0] + "> call function", frame.f_code.co_name)
elif event == "return":
print("<" + "-" * indent[0], "exit function", frame.f_code.co_name)
indent[0] -= 2
return tracefunc
sys.setprofile(tracefunc)
main() #or whatever function you wanna trigger
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment