Reputation: 9370
The following code would work to sympify logical expressions:
sympify('a&b') # And(a, b)
sympify('a|b') # Or(a, b)
But how do I get a result of Not(a)
?
Upvotes: 4
Views: 83
Reputation: 6693
It turns out the symbol you are looking for is ~
. See the following:
>>> from sympy import sympify
>>> sympify('a&b')
And(a, b)
>>> sympify('a|b')
Or(a, b)
>>> sympify('~a')
Not(a)
Upvotes: 8