psamm.expression.boolean – Boolean expressions

Representations of boolean expressions and variables.

These classes can be used to represent simple boolean expressions and do evaluation with substitutions of particular variables.

class psamm.expression.boolean.And(*args)

Represents an AND term in an expression.

class psamm.expression.boolean.Expression(arg, _vars=None)

Boolean expression representation.

The expression can be constructed from an expression string of variables, operators (“and”, “or”) and parenthesis groups. For example,

>>> e = Expression('a and (b or c)')
has_value()

Return True if the expression has no variables.

root

Return root term, variable or boolean of the expression.

substitute(mapping)

Substitute variables using mapping function.

value

The value of the expression if fully evaluated.

variables

Immutable set of variables in the expression.

class psamm.expression.boolean.Or(*args)

Represents an OR term in an expression.

exception psamm.expression.boolean.ParseError(*args, **kwargs)

Signals error parsing boolean expression.

exception psamm.expression.boolean.SubstitutionError

Error substituting into expression.

class psamm.expression.boolean.Variable(symbol)

Represents a variable in a boolean expression