title: Handle undeclared dict key in Python
body: <p>In my Ruby application I have a hash table:</p>
  
  <pre class="lang-rb prettyprint-override"><code>c = {:sample =&gt; 1,:another =&gt; 2}
  </code></pre>
  
  <p>I can handle the table like this:</p>
  
  <pre class="lang-rb prettyprint-override"><code>[c[:sample].nil? , c[:another].nil? ,c[:not_in_list].nil?]
  </code></pre>
  
  <p>I'm trying to do the same thing in Python. I created a new dictionary:</p>
  
  <pre><code>c = {"sample":1, "another":2}
  </code></pre>
  
  <p>I couldn't handle the nil value exception for:</p>
  
  <pre><code>c["not-in-dictionary"]
  </code></pre>
  
  <p>I tried this:</p>
  
  <pre><code>c[:not_in_dictionery] is not None
  </code></pre>
  
  <p>and it is returning an exception instead of <code>False.</code> How do I handle this?</p>