title: Custom dictionary lookup in Python
body: <p>if I have a dictionary like this</p>
  
  <pre><code>&gt;&gt;&gt; d = {10: 3, 100: 2, 1000: 1}
  </code></pre>
  
  <p>I can type something like:</p>
  
  <pre><code>&gt;&gt;&gt; d.get(10), d.get(100), d.get(1000)
  (3, 2, 1)
  </code></pre>
  
  <p>Though I want that if the given key is not found, the value corresponding to the nearest key respect the given key is returned:</p>
  
  <pre><code>&gt;&gt;&gt; d.get(20), d.get(60), d.get(200)
  (3, 2, 2)
  </code></pre>
  
  <p>Instead the result in Python is</p>
  
  <pre><code>(None, None, None)
  </code></pre>
  
  <p>What's a Pythonic way to implement the behavior I described?</p>
  
  <p>Thanks</p>