New submission from Serhiy Storchaka <storchaka+cpyt...@gmail.com>:
Currently ast.dump() in multiline mode (see issue37995) appends closing parenthesis to the end of the line: >>> import ast >>> node = ast.parse('spam(eggs, "and cheese")') >>> print(ast.dump(node, indent=3)) Module( body=[ Expr( value=Call( func=Name(id='spam', ctx=Load()), args=[ Name(id='eggs', ctx=Load()), Constant(value='and cheese')], keywords=[]))], type_ignores=[]) It uses vertical space more efficiently (which is especially important on Windows console). But I got a feedback about output closing parenthesis on separate lines (msg363783): Module( body=[ Expr( value=Call( func=Name(id='spam', ctx=Load()), args=[ Name(id='eggs', ctx=Load()), Constant(value='and cheese') ], keywords=[] ) ) ], type_ignores=[] ) It looks more "balanced", but less vertical space efficient. It adds almost 300 lines to 57 examples in Doc/library/ast.rst. And after omitting optional list arguments like keywords=[] and type_ignores=[] (see issue39981) the stairs of parenthesis will look even longer. The proposed PR changes the output of ast.dump() by moving closing parenthesis on separate lines. I am still not sure what output is better. ---------- components: Library (Lib) messages: 364391 nosy: benjamin.peterson, pablogsal, rhettinger, serhiy.storchaka, terry.reedy priority: normal severity: normal status: open title: Output closing parenthesis in ast.dump() on separate line type: enhancement versions: Python 3.9 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue39989> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com