title: Got UnboundLocalError: Local Variable referenced before assignment, but it wasn't
body: <p>I am completely stumped. I looked at other answers to this same question, but none seemed to give the slightest answer as to why I myself am getting this error. I have pretty much 2 of the exact same programs running the same code with the exception of some URL's and Product ID's that it reads from files. The programs are a little bit long, so I put them on <a href="http://pastebin.com/AkVJAHrD" rel="nofollow">Pastebin Here</a>. I don't expect you to read all the code, the error occurs in the main function where I define PID and then try to use it later in the function. Why does one work perfectly fine and the other does not? As far as I can see they are the same in that part, but maybe I missed something! Any help is appreciated!
  Thanks!</p>
  
  <p>PS: The error I receive is:</p>
  
  <pre><code>UnboundLocalError: Local variable 'PID' referenced before assignment
  </code></pre>