title: How to delete a global variable from inside a function?
body: <p>I have a global variable <code>ser</code> which I need to delete under certain circumstances:</p>
  
  <pre><code>global ser
  ser = ['some', 'stuff']
  
  def reset_ser():
      print('deleting serial configuration...')
      del ser
  </code></pre>
  
  <p>If I call <code>reset_ser()</code> I get the error:</p>
  
  <pre><code>UnboundLocalError: local variable 'ser' referenced before assignment
  </code></pre>
  
  <p>If I give the global variable to the function as an input I do not get the error, but the variable does not get deleted (I guess only inside the function itself). Is there a way of deleting the variable, or do I e.g.have to overwrite it to get rid of its contents?</p>