dict to boolean expression, how to?
marco.nawijn at colosso.nl
marco.nawijn at colosso.nl
Fri Aug 1 11:07:20 EDT 2014
Hi,
Are you aware of the Python operator module?
It provides function equivalents of all (most?)
python operator. So instead of a==b, you can
state operator.eq(a,b). As a result, you can
loop over the key/value pairs in the dict and
built your logic with the operator.eq,
operator.and_, and operator.or_ (notice the
trailing underscore to avoid clashing with
normal "and" and "or" statements.
Marco
More information about the Python-list
mailing list