For example, there is a given string
( a > b or a > c) and a < d
in python. I want to at first extract expression and logical operator from this statement, then check it one by one, such as
if a > b then check a < d, else check a > c then check a < d
I don‘t know how to extract it in the logical order. Thanks a lot for help.
You can use Abstract Syntax Trees module to do this. It allows you to parse Python codes and work with its abstract syntax tree.
Output for this code is: