title: Doing Class.objects.filter(...) pattern in python
body: <p>I am looking to use the pattern used in django models of <code>Model.objects.filter(...)</code> to build filters across data. This would probably be a good use case of pandas, but I'm more interested in improving my python (first) before trying that out.</p>
  
  <p>If I have the following data:</p>
  
  <pre><code>DATA = [
      {'id': 1, 'name': 'brad', 'color':'red'},
      {'id': 2, 'name': 'sylvia', 'color':'blue'},
  ]
  </code></pre>
  
  <p>I would like to build something similar to the following:</p>
  
  <pre><code>class MyData:
      objects = &lt;something&gt;
  </code></pre>
  
  <p>And set the <code>objects</code> equivalent to a "ModelManager" and then do the filtering from there so that I can call:</p>
  
  <pre><code>MyData.objects.filter(id&gt;1)
  </code></pre>
  
  <p>And get:</p>
  
  <pre><code>[
      {'id': 2, 'name': 'sylvia', 'color':'blue'}
  ]
  </code></pre>
  
  <p>Of course I can do something as simple as:</p>
  
  <pre><code>res = [_ for _ in DATA if _['id'] &gt; 1]
  </code></pre>
  
  <p>But I'm more interested in designing the pattern itself -- the trivial nature of the example is just meant to show what I'm looking to accomplish.</p>
  
  <p>What would be a good, basic way to do this properly? Here's the relevant class in django for it: <a href="https://github.com/django/django/blob/master/django/db/models/query.py#L185" rel="noreferrer">https://github.com/django/django/blob/master/django/db/models/query.py#L185</a>.</p>