title: Why do these print() calls appear to execute in the wrong order?
body: <p>weird.py:</p>
  
  <pre><code>import sys
  
  def f ():
      print('f', end = '')
      g()
  
  def g ():
      1 / 0
  
  try:
      f()
  except:
      print('toplevel', file = sys.stderr)
  </code></pre>
  
  <p>Python session:</p>
  
  <pre><code>Python 3.4.2 (v3.4.2:ab2c023a9432, Oct  6 2014, 22:16:31) [MSC v.1600 64 bit (AM
  D64)] on win32
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import weird
  toplevel
  f&gt;&gt;&gt;
  </code></pre>
  
  <p>Why does "toplevel" print before "f"?</p>
  
  <p>This doesn't happen if the <code>end = ''</code> or the <code>file = sys.stderr</code> are removed.</p>