q = False
r = True
test = ['p and not q', 'not not p', 'not(p and q)', 'q or not p and r',
    'q or not (p and r)', 'p or q or r', 'p or q or r and False']
for t in test:
    res = boolExpr.parseString(t)[0]
print(t, '\n', res, '=', bool(res), '\n')
Alternative to eval in Python