2013年7月24日 Haoyi Li <haoyi.sg at gmail.com>: > How many other people in the world are doing AST manipulations to want this? I wrote a project called astoptimizer which rewrites AST to implement some static optimizations. http://bitbucket.org/haypo/astoptimizer/ I need a get_constant() method checking if a node is "a constant". It creates a tuple from a ast.Tuple tree for example. Having to "encode/decode" (create tuple <=> create ast.Tuple) regulary is not efficient. I would also like a first pass in the optimizer which would replace ast.Num, ast.Str, ast.NameConstant, ast.Tuple, etc. to a generic ast.Constant which contains directly the Python object. See my get_constant() method: https://bitbucket.org/haypo/astoptimizer/src/dfb2c702cb14785320ac34b868d5e1270f910825/astoptimizer/optimizer.py?at=default#cl-289 Victor