Q:

Python definitions relying on other undefined definitions?

I didn't know what to title this, so if anyone wants to edit it: Go ahead.
def Function_A()
 print "We're going to function B!"
 Function_B()

def Function_B()
 print "We made it!'

This is a beginner question, but the solution hasn't occurred to me as I've been spoiled by compiled languages. You can see here, Function_A leads to Function_B. At runtime, Function_B will not be defined when Function_A is called, so it can't happen. How do I get around this?

A:

In Python, functions do not need to be defined in order of use. As long as it's defined somewhere before the function is called at runtime it should work. This is because Function_A() is not actually evaluated until it's called, which in this is case is at the bottom of the this test.py file at which point Function_B() is already defined.
test.py:
def Function_A():
    print "We're going to function B!"
    Function_B()

def Function_B():
    print "We made it!!"

Function_A()

Example run:

mahmoud:~$ python test.py
  We're going to function B!
  We made it!!

