As written, both functions are being defined, but neither of the functions is called.
If you call Function_A
before the definition of Function_B
you will get an error:
def Function_A():
print "We're going to function B!"
Function_B()
Function_A() # will fail
def Function_B():
print "We made it!"
If you call Function_A
after the definition of Function_B
everything will work fine:
def Function_A():
print "We're going to function B!"
Function_B()
def Function_B():
print "We made it!"
Function_A() # will succeed
The interpreter executes the file from beginning to end, defining and calling functions as they come along. The function bodies will only be closely looked at when the function is called.
When executing Function_A
and reaching its second line, the interpreter will look in the global namespace to find something called Function_B
. In the first example there hasn't been anything defined yet, while in the second example there is a Function_B
that can be called.