Skip to content

Instantly share code, notes, and snippets.

@m0xb
Created October 4, 2017 22:54
Show Gist options
  • Select an option

  • Save m0xb/6431e4d7a0e125255c21c72d14819784 to your computer and use it in GitHub Desktop.

Select an option

Save m0xb/6431e4d7a0e125255c21c72d14819784 to your computer and use it in GitHub Desktop.
$ cat countdown_recursive_debug.py
def countdown(n):
print(f"DEBUG: enter countdown({n})")
print(n)
if n > 1:
countdown(n - 1)
print(f"DEBUG: exit countdown({n})")
countdown(5)
$ python3 countdown_recursive_debug.py
DEBUG: enter countdown(5)
5
DEBUG: enter countdown(4)
4
DEBUG: enter countdown(3)
3
DEBUG: enter countdown(2)
2
DEBUG: enter countdown(1)
1
DEBUG: exit countdown(1)
DEBUG: exit countdown(2)
DEBUG: exit countdown(3)
DEBUG: exit countdown(4)
DEBUG: exit countdown(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment