title: Dynamically evaluating simple boolean logic in Python
body: <p>I've got some dynamically-generated boolean logic expressions, like:</p>
  
  <ul>
  <li>(A or B) and (C or D)</li>
  <li>A or (A and B)</li>
  <li>A</li>
  <li><em>empty - evaluates to True</em></li>
  </ul>
  
  <p>The placeholders get replaced with booleans. Should I,</p>
  
  <ol>
  <li>Convert this information to a Python expression like <code>True or (True or False)</code> and <code>eval</code> it?</li>
  <li>Create a binary tree where a node is either a <code>bool</code> or <code>Conjunction</code>/<code>Disjunction</code> object and recursively evaluate it?</li>
  <li>Convert it into nested S-expressions and use a Lisp parser?</li>
  <li>Something else?</li>
  </ol>
  
  <p>Suggestions welcome.</p>