NameError: global name 'AlreadyExists' is not defined when using try/except within a function
<p>I know many of these questions exist but I can't seem to find one that works for the problem I am having.</p>

<p>I have the following:</p>

<pre><code>def function():
  try:
    # function to create a table on hbase
  except AlreadyExists, ae:
    print "WARN: " + ae.message 
</code></pre>

<p>when I call it from another python script it gives me </p>

<pre><code>NameError: global name 'AlreadyExists' is not defined 
</code></pre>

<p>...but if I remove the <code>def function()</code> and run it on its own, it works and doesn't complain about the global name.</p>

<p>I tried putting <code>global AlreadyExists</code> and that didn't work.  I also looked at this <a href="http://stackoverflow.com/questions/6060865/nameerror-global-not-defined-when-using-try-except">similar problem</a> but I'm not sure how to apply it because it works on its own (without me having to import anything specific, but as soon as I wrap it in a function it fails).</p>

<p>Any suggestions?</p>
