This is my first post here, and I hope that my question is clear and formatted correctly...
I have two dictionaries. The first dictionary contains what I'm calling "Option Expressions" as keys and arbitrary items for values:
dict1 = {'((opt1 OR opt4 OR opt6) AND NOT opt7)': 'Yellow Roof', '((opt2 AND opt3) XOR opt5': 'Purple Scooter'}
print(dict1)
{'((opt1 OR opt4 OR opt6) AND NOT opt7)': 'Yellow Roof',
'((opt2 AND opt3) XOR opt5': 'Purple Scooter'}
The second dictionary contains the options from dict1 as keys and whether or not they were "Accepted" or "Rejected" as values:
dict2 = {'opt1': 'Accepted', 'opt2': 'Rejected', 'opt3': 'Rejected','opt4': 'Accepted', 'opt5': 'Accepted', 'opt6': 'Rejected','opt7': 'Accepted'}
print(dict2)
{'opt1': 'Accepted',
'opt2': 'Rejected',
'opt3': 'Rejected',
'opt4': 'Accepted',
'opt5': 'Accepted',
'opt6': 'Rejected',
'opt7': 'Accepted'}
How would I go about evaluating the expressions from dict1 as True or False to determine which items were selected based on whether opt's from dict2 were accepted or rejected?
My initial thought was to replace the opt's in the expressions with 1 for accepted and 0 for rejected to have something like:
((1 OR 1 OR 0) AND NOT 1) Which would evaluate as False
and
((0 AND 0) XOR 1) Which would evaluate as True
I've been doing some research into pyparsing and think it would be useful here, though I am not entirely sure how best to utilize it.
I am applying boolean logic:
AND: True if and only if both sides are true
OR: True if either side is true
NOT/(AND NOT): Changes true to false and false to true
XOR: True if one side is true (but not both)
optvalues bool-normalized or can they have a different value thanAcceptedorRejected? - zwerdict1... - Julien