Python nicest way to take boolean expression string apart
<p>I have a boolean expression string, that I would like to take apart:</p>

<pre><code>condition = "a and (b or (c and d))"
</code></pre>

<p>Or let's say:<br />
I want to be able to access the string contents between two parenthesis.<br />
I want following outcome:</p>

<pre><code>"(b or (c and d))"
"(c and d)"
</code></pre>

<p>I've tried the following with regular expressions (not really working)</p>

<pre><code>x = re.match(".*(\(.*\))", condition)
print x.group(1)
</code></pre>

<p>Question:<br />
What is the nicest way to take a boolean expression string apart?</p>
