How does python implement mutual recursion?
Moving to python with C/Java background, I recently had to implement a mutual recursion, but something in python is bothering me: since a python program is interpreted line by line, if I have two functions one after another in the same python file: def A(n): B(n-1) # if I add A(1) here, it gives me an error def B(n): if n <= 0: return else: A(n-1) When the interpreter is reading A , B is not yet defined, however this code does not give me an error TL;DR My understanding is that, when def is interpreted, python adds an entry to some local name space locals() with {"function name": function