I've got some dynamically-generated boolean logic expressions, like:
The placeholders get replaced with booleans. Should I,
True or (True or False)
and eval
it?bool
or Conjunction
/Disjunction
object and recursively evaluate it?Suggestions welcome.
It shouldn't be difficult at all to write a evaluator that can handle this, for example using pyparsing. You only have a few operations to handle (and, or, and grouping?), so you should be able to parse and evaluate it yourself.
You shouldn't need to explicitly form the binary tree to evaluate the expression.