Untitled

Run Settings
LanguagePython
Language Version
Run Command
import ast body = """1+1<<2 1+1<2 2+2==3 '1111<2' #1+1<2 """ tree = ast.parse(body) print(ast.dump(tree, indent=4)) for expr in tree.body: if isinstance(expr.value, ast.Compare) and isinstance(expr.value.ops[0], ast.Lt): expr.value.ops[0] = ast.Gt() print(ast.unparse(tree)) print("visit" *5) tree = ast.parse(body) class RewriteOp(ast.NodeTransformer): def visit_Lt(self, node): return ast.Gt() node = RewriteOp().visit(tree) print(ast.unparse(node))
Editor Settings
Theme
Key bindings
Full width
Lines