title: Define functions at the top or at the bottom of a script?
body: <p>In Python all functions must be defined before they can be accessed. This leaves two choices for writing a script:</p>
  
  <ol>
  <li><p>Define the functions at the top:</p>
  
  <pre><code>def f1():
      # something
  
  def f2():
      # something
  
  # Call f1
  f1()
  # Call f2
  f2()
  </code></pre></li>
  <li><p>Define the functions at the bottom:</p>
  
  <pre><code>def main():
      # Call f1
      f1()
      # Call f2
      f2()
  
  def f1():
      # something
  
  def f2():
      # something
  
  # Call main() at the bottom, after all the functions have been defined.
  if __name__ == '__main__':
      main()
  </code></pre></li>
  </ol>
  
  <p>Coming from Fortran, I was used to defined functions at the bottom, but I've seen numerous Python scripts where defining them at the top seems to be prefered.</p>
  
  <p>Is one of these options more Pythonic/recommended than the other? If so, why?</p>
  
  <p><strong>(I am not asking for an "opinion", I'm asking for a well-argumented reason as to why either one of these is preferred, or if they are both considered equally valid.)</strong></p>