title: Can you do LINQ-like queries in a language like Python or Boo?
body: <p>Take this simple <em>C# LINQ</em> query, and imagine that <code>db.Numbers</code> is an <em>SQL</em> table with one column <code>Number</code>:</p>
  
  <pre><code>var result = 
      from n in db.Numbers
          where n.Number &lt; 5
          select n.Number;
  </code></pre>
  
  <p>This will run very efficiently in <em>C#</em>, because it generates an <em>SQL</em> query something like</p>
  
  <pre><code>select Number from Numbers where Number &lt; 5 
  </code></pre>
  
  <p>What it <strong>doesn't</strong> do is select <em>all</em> the numbers from the database, and then filter them in <em>C#</em>, as it might appear to do at first.</p>
  
  <p><em>Python</em> supports a similar syntax:</p>
  
  <pre><code>result = [n.Number for n in Numbers if n.Number &lt; 5]
  </code></pre>
  
  <p>But it the <code>if</code> clause here does the filtering on the client side, rather than the server side, which is much less efficient.</p>
  
  <p>Is there something as efficient as <em>LINQ</em> in <em>Python</em>?  (I'm currently evaluating <em>Python</em> vs. <em>IronPython</em> vs. <em>Boo</em>, so an answer that works in any of those languages is fine.)</p>