<div dir="ltr">Wouldn't it be nice if this<div><br></div><div><div>>>> import ast</div><div>>>> print repr(ast.parse("(1 + 1)").body[0].value)</div><div><_ast.BinOp object at 0x0000000001E94B38></div>

</div><div><br></div><div style>printed something more useful?</div><div style><br></div><div style>>>> print repr(ast.parse("(1 + 1)").body[0].value)<br></div><div style>BinOp(left=Num(n=1), op=Add(), right=Num(n=1))<br>

</div><div style><br></div><div style>I've been doing some work on <a href="https://github.com/lihaoyi/macropy">macropy</a>, which uses the ast.* classes extensively, and it's annoying that we have to resort to dirty-tricks like monkey-patching the AST classes (for CPython 2.7) or even monkey-patching __builtin__.repr (to get it working on PyPy) just to get </div>

<div style><br></div><div style>    eval(repr(my_ast)) == my_ast </div><div style><br></div><div style>to hold true. And a perfectly good solution already exists in the ast.dump() method, too! (It would also be nice if "==" did a structural comparison on the ast.* classes too, but that's a different issue).</div>

<div style><br></div><div style>-Haoyi</div></div>