selective printing from a list
<p>Say for an example, I've a list like this:</p>

<pre><code>q_list = [('94.vmtest2', 'sgmops', 'Andy Hays', '27/04 00:27:26', 'C', '27/04 00:28:31', 'vmtest1.hep', 'express', '00:00:10', '00:01:04'), 
          ('96.vmtest2', 'sgmops', 'John Dee', '27/04 01:27:26', 'C', '27/04 01:28:33', 'vmtest1.hep', 'short', '00:00:09', '00:01:06'),
          ('99.vmtest2', 'sgmops', 'Andy Hays', '27/04 07:19:56', 'C', '27/04 07:21:12', 'vmtest1.hep', 'express', '00:00:10', '00:01:14'), 
          ('103.vmtest2', 'sgmops', 'John Dee', '27/04 14:08:00', 'C', '27/04 14:09:16', 'vmtest1.hep', 'express', '00:00:10', '00:01:16'),
          ('102.vmtest2', 'sgmops', 'John Dee', '27/04 14:02:38', 'C', '27/04 14:10:12', 'vmtest1.hep', 'short', '00:00:10', '00:01:10')]
</code></pre>

<p>which is formed from the log files. and then I have a dictionary like this:</p>

<pre><code>q_dict = {'username': 'johndee', 'queue': 'short'}
</code></pre>

<p>which is formed from a query string (the user input). What I want is to print [first 8 items of] the only lines from the list match with the value in the dictionary. In this case, I'll only print these two lines:    </p>

<pre><code>96.vmtest2   sgmops  John Dee  27/04 01:27:26  C  27/04 01:28:33  vmtest1.hep  short
102.vmtest2  sgmops  John Dee  27/04 14:02:38  C  27/04 14:10:12  vmtest1.hep  short
</code></pre>

<p>In fact it doesn't have to be a dictionary at all; the user input (command-line argument) is like this:</p>

<pre><code>'formatDate(%m/%d) == 4/27 &amp;&amp; username == John Dee &amp;&amp; queue == short'
</code></pre>

<p>and I'm creating the dictionary out of that. Any idea how can I do that? Thanks in advance for any help. Cheers!!</p>
