title: How to "terminate" inside of init
body: <p>I have a class that does some sanity checks inside <code>__init__</code>. If some of these fail, I want to stop processing <code>__init__</code>.</p>
  
  <p>Example:</p>
  
  <pre><code>class MyClass(object):
      def __init__(self, hostname, conn=None, user=None, passwd=None):
          # SNIP (code to check if connection was supplied, if not user/pass)
          if not conn.is_logged_in():
              if not conn.Login():
                  raise LoginFailed("Failed to login to '%s'" % hostname)
                  return
          # some code that relies on valid connection   
  </code></pre>
  
  <p>If I want to cease processing after this first sanity check, how can this be done? The actual code I'm writing establishes a connection to a REST service, so my first sanity check is to test the provided connection, or, if provided a username and password instead, establish the connection in <code>__init__()</code>.</p>
  
  <p>Obviously if the connection fails, I don't want to execute the subsequent tasks that rely on the connection. Essentially I want the object creation to fail. </p>
  
  <p>Any suggestions? Thanks.</p>