Nick Coghlan <ncogh...@gmail.com> added the comment:

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.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34822>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to