title: What are acceptable use-cases for python's `assert` statement?
body: <p>I often use python's assert statement to check user input and fail-fast if we're in a corrupt state. I'm aware that assert gets removed when python with the <code>-o</code>(optimized) flag. I personally don't run any of my apps in optimized mode, but it feels like I should stay away from assert just in-case.</p>
  
  <p>It feels much cleaner to write</p>
  
  <pre><code>assert filename.endswith('.jpg')
  </code></pre>
  
  <p>than</p>
  
  <pre><code>if not filename.endswith('.jpg'):
      raise RuntimeError
  </code></pre>
  
  <p>Is this a valid use case for assert? If not, what would a valid use-case for python's <code>assert</code> statement be? </p>