This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients BTaskaya, benjamin.peterson, brett.cannon, gvanrossum, nascheme, ncoghlan, pablogsal, serhiy.storchaka, thautwarm, veky
Date 2020-03-07.13:12:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
The one thing in the PR that makes me slightly wary is the point Vedran raised: in the old AST _Unparser code, the fact that index tuples containing slices should be printed without parentheses was encapsulated in the ExtSlice node type, but with Index and ExtSlice removed, that behaviour is now instead implemented by duplicating the visit_Tuple logic directly in visit_Subscript, purely to omit the surrounding parens.

So I agree that the parse tree simplification is an improvement, but I'm wondering if it might make sense to add an "is_subscript" attribute to expression nodes.

That way the Tuple vs ExtSlice and Expr vs Index distinctions would be preserved, but the representation of those distinctions would change in a way that meant that most consuming code didn't need to care that the distinctions existed (ExtSlice would become a Tuple with is_subscript set to True, and similarly, Index would become Expr instances with is_subscript set to True).

It's been so long since I changed the AST, though, that I'm not sure how painful adding that attribute would be.
Date User Action Args
2020-03-07 13:12:06ncoghlansetrecipients: + ncoghlan, gvanrossum, brett.cannon, nascheme, benjamin.peterson, serhiy.storchaka, veky, pablogsal, thautwarm, BTaskaya
2020-03-07 13:12:05ncoghlansetmessageid: <>
2020-03-07 13:12:05ncoghlanlinkissue34822 messages
2020-03-07 13:12:05ncoghlancreate