Skip to content

Instantly share code, notes, and snippets.

@a-recknagel
Last active August 8, 2019 07:39
Show Gist options
  • Save a-recknagel/55716d6a9b333ccf1455213a54507320 to your computer and use it in GitHub Desktop.
Save a-recknagel/55716d6a9b333ccf1455213a54507320 to your computer and use it in GitHub Desktop.
Callstacks
# no callstack, we directly crash through to the intepreter
>>> raise ValueError()
Traceback (most recent call last):
File "<input>", line 1, in <module>
ValueError
# we raise in a function, we crash to line two, which called the function
>>> def a():
... raise ValueError()
...
>>> a()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "<input>", line 2, in d
ValueError
# now the long (but not much more complicated) version, if we crash we just go to the most recent call site
>>> def d():
... raise ValueError()
... def c():
... d()
... def b():
... c()
... def a():
... b()
...
>>> a()
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "<input>", line 8, in a
File "<input>", line 6, in b
File "<input>", line 4, in c
File "<input>", line 2, in d
ValueError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment