Is there anything like jQuery selectors for Python objects?
<p>Selectors, like jQuery selectors, CSS selectors, and XPATH are cool.</p>

<p><strong>Question</strong> Has anyone written something like it for Python objects which are expressed as nested primitives (lists, dicts, tuples, etc.)?</p>

<p>(Note: If such objects need be acyclic, I wouldn't consider that too extreme a limitation for most cases.)</p>

<p><strong>Simple example</strong> If we had data like,</p>

<pre><code>x = [
  {'xyz': 3},
  {'xyz': 4}
]
</code></pre>

<p>then, it'd be nice if one could write something like <code>sel("[].xyz", x)</code> and get back (perhaps a reference to) <code>[3, 4]</code>.</p>

<p><strong>Second simple example</strong> If we had data like,</p>

<pre><code>x = [{'a': {'b': [1, 2]}}]
</code></pre>

<p>Then, perhaps we could write something like <code>sel("[].a.b[]", x)</code> and get <code>[1, 2]</code>.</p>
