title: Python try/except ... function always returns false
body: <p>I'm trying to figure out the problem in this short paragraph of code.  Any help would be appreciated.  Regardless of what I specify User.email to be, it always returns false.</p>
  
  <pre><code>def add(self):
  
      #1 -- VALIDATE EMAIL ADDRESS
      #Check that e-mail has been completed
      try:
          #Validate if e-mail address is in correct format
          if (isAddressValid(self.email) == 0):
              self.errors['email'] = 'You have entered an invalid e-mail address';
              return 0
  
      except NameError:
          self.errors['email'] = 'Please enter your e-mail'
          return 0
  
  &gt;&gt;&gt; u = User()
  &gt;&gt;&gt; u.email = 'test@example.com'
  &gt;&gt;&gt; u.add()
  0
  &gt;&gt;&gt; print u.errors
  {'email': 'Please enter your e-mail'}
  </code></pre>
  
  <p>I have confirmed that the false being returned is coming from except NameError.</p>
  
  <p>Also, isAddressValid() is just a method to check the structure of an e-mail address.</p>
  
  <p>Thanks.</p>