First off, match
literally matches the entire string to see if it matches the expression, which it clearly does not. Lastly, if you are trying to parse the entire input expression as such, it should be parsed into an abstract syntax tree - a stack will probably not represent the intended expression unless you ignore order of operations or have some other ways to compensate for this. Correcting the last one is out of the scope of this question.
To find a value, you want to use search
As an aside, there is an operator
module which you may consider looking into.
>>> log_op.match(expression)
>>> log_op.search(expression)
<_sre.SRE_Match object at 0x22068b8>
Note that match returned nothing, but search did, so we will use that, and see how you compare that
>>> log_op.search(expression).group().lower()
'not'
>>> log_op.search(expression).group().lower() is "not"
False
>>> log_op.search(expression).group().lower() == "not"
True
As str
objects are instantiated, they won't have the same identity as other instances even if values are equal, so you have to compare using an equality comparison as that comparison operator is implemented for those objects in the typically expected manner.