title: python scoping and del
body: <p>I am having difficulty to understand how del works in python. 
  Should not del delete the object a after print it's value ? </p>
  
  <pre><code>def f1():
      a = 5
      def f2():
          print('a: ', a)
          del a
      f2()
      print(a)
  
  f1()
  </code></pre>
  
  <p>By executing this function I am getting error: </p>
  
  <blockquote>
    <p>UnboundLocalError: local variable 'a' referenced before assignment.</p>
  </blockquote>
  
  <p>But if I don't delete a then it's working properly.</p>
  
  <pre><code>def f1():
      a = 5
      def f2():
          print('a: ', a)
          # del a
      f2()
      print(a)
  
  f1()
  </code></pre>
  
  <p>Question: </p>
  
  <ol>
  <li>is del working at the same time as printing?</li>
  <li>if yes then it should be okay to understand but if not then is there anything I am missing?  </li>
  </ol>