I propose a new syntax to get the ast of an expression instead of always being evaluated to allow expressions to be passed to function.
The main syntax for forcing python to return the ast of an expression would be \(expression)
where expression
is any python expression.
For example \(my_var+2)
would be equal to ast.Binop(ast.Name("my_var" , ast.Load() ) , ast.Add , ast.Constant(2))
The main use case would be simplify expressions such thoughts used in boolean indexing. Instead of having to write dataframe[(dataframe.column_1 > 5) & (dataframe.column_2< 10)]
you could instead write dataframe[\((column_1 > 5) & (column_2 <10))
It would also make creating an ast transformer simpler and easier by allowing static ast nose to be written in python directly instead of having to create the node directly.