title: Why does Python throw a KeyError when accessing an unset property?
body: <p>What are the rationale and implications for throwing <code>KeyError</code> instead of returning <code>None</code> when accessing an unset property on a Python dictionary?</p>
  
  <p>I know that language design involves trade-offs, some of them based on practical concerns and some based primarily on philosophy. From a computer science perspective, why has Python been designed in this way?</p>
  
  <h3>A couple of notes to frame the question</h3>
  
  <ul>
  <li>I'm primarily curious to know if this was a practical decision (i.e., it gives the developer more options to recover from the error than just returning <code>None</code>), or if the choice was philosophical (i.e., "accessing an unset property is, in Guido's opinion, an exceptional case").</li>
  <li>Python's <code>dict.get</code> function has this functionality, but the literal notation appears to be optimizing for the case where the program considers an unset value exceptional.</li>
  <li>It's worth noting that exception handling is considered by some to be hard to reason about because it involves <a href="http://www.cs.virginia.edu/~weimer/p/weimer-toplas2008.pdf" rel="nofollow">a control flow that is distinct from the main program</a></li>
  <li>If Python returned <code>None</code> instead of raising an exception, a program could still check for the key's existence prior to accessing its value if it did want to treat unset and <code>None</code> values differently. But since we wouldn't have access to the exception programming flow, I'm interested to learn what we might lose?</li>
  </ul>