title: Why Python allows def functions inside for loop
body: <p>I'm new at Python, but I tried something and it was ambiguous for me.
  Why Python allows doing def of function inside a loop ? and how I can benefit from that ?</p>
  
  <pre><code>for i in range(2):
    def f():
       print 'f'
  
    f()
  </code></pre>