I'm trying to build a Boolean expression, based on (unpredictable) user input. I find that I'm building a string that looks proper, but doesn't work. I've looked at python.org, Google and Stackoverflow and couldn't find what goes wrong here.
Example of the code:
print stringDing
newVariable = stringDing.replace('False','0')
print newVariable
print bool(newVariable)
Output from this:
False or False or False
0 or 0 or 0
True
Yet when the string is pasted into python, python responds as expected:
>>> False or False or False
False
I think I need to build this as a string because the user can add 'OR', 'AND' and brackets, which I would need to fit in at the proper place.
How to proceed?