Skip to content

Instantly share code, notes, and snippets.

@mahenzon
Created August 12, 2020 11:00
Show Gist options
  • Save mahenzon/d77361a1bd44f138e706ae4734007ee6 to your computer and use it in GitHub Desktop.
Save mahenzon/d77361a1bd44f138e706ae4734007ee6 to your computer and use it in GitHub Desktop.
Trace calls made to the decorated function
def trace():
"""
Trace calls made to the decorated function.
@trace("____")
def fib(n):
....
>>> fib(3)
--> fib(3)
____ --> fib(2)
________ --> fib(1)
________ <-- fib(1) == 1
________ --> fib(0)
________ <-- fib(0) == 1
____ <-- fib(2) == 2
____ --> fib(1)
____ <-- fib(1) == 1
<-- fib(3) == 3
"""
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment