title: Use of True, False, and None as return values in Python functions
body: <p>I think that I fully understand this, but I just want to make sure since I keep seeing people say to <em>never ever</em> test against <code>True</code>, <code>False</code>, or <code>None</code>.</p>
  
  <p>They suggest that routines should raise an error rather than return False or None. Anyway, I have many situations where I simply want to know if a flag is set or not so my function returns True or False. There are other situations where I have a function return None if there was no useful result. From my thinking, neither is problematic so long as I realize that I should never use:</p>
  
  <pre><code>if foo == True
  if foo == False
  if foo == None
  </code></pre>
  
  <p>and should instead use:</p>
  
  <pre><code>if foo is True
  if foo is False
  if foo is None
  </code></pre>
  
  <p>since True, False, and None are all singletons and will always evaluate the way I expect when using "is" rather than "==". Am I wrong here?</p>
  
  <p>Along the same lines, would it be more Pythonic to modify the functions that sometimes return None so that they raise an error instead?</p>
  
  <p>Say I have an instance method called "get_attr()" that retrieves an attribute from some file. In the case where it finds that the attribute I requested does not exist, is it appropriate to return None? Would it be better to have them raise an error and catch it later?</p>