[issue33520] ast.Tuple has wrong col_offset

2018-05-15 Thread Isaiah Peng
New submission from Isaiah Peng : The `col_offset` of the ast.Tuple node is set to the column offset of the first element, shown in code: >>> a = "{1,2,3}" >>> b = ast.parse(a).body[0] >>>

[issue33520] ast.Tuple has wrong col_offset

2018-05-15 Thread Łukasz Langa
Łukasz Langa added the comment: This is because technically parentheses aren't part of the tuple. They are just organizational and unnecessary for the tuple to be recognized by the parser. Those two are equivalent: >>> ast.parse("(1,2,3)").body[0].value.col_offset 1 >>> ast.parse("(1)

[issue33520] ast.Tuple has wrong col_offset

2018-05-15 Thread Łukasz Langa
Łukasz Langa added the comment: For comparison, a tuple without parentheses: >>> ast.parse("1,2,3").body[0].value.col_offset 0 -- ___ Python tracker ___ __

[issue33520] ast.Tuple has wrong col_offset

2018-05-15 Thread Isaiah Peng
Isaiah Peng added the comment: Thanks for the reply, that's quite reasonable, especially take the generator expression case into consideration. However I found this is not consistent with empty tuple: >>> a = "()" >>>

[issue33520] ast.Tuple has wrong col_offset

2018-05-15 Thread Isaiah Peng
Isaiah Peng added the comment: > It's true that the parenthesis is required to construct a tuple Sorry, I mean the parenthesis is *not* required. -- ___ Python tracker ___ ___

[issue33520] ast.Tuple has wrong col_offset

2018-05-15 Thread R. David Murray
R. David Murray added the comment: No, the parenthesis are never part of the tuple itself, even if you can't write syntactically correct code without them. They just syntactically group the expression list to isolate it from the surrounding context. It's the same principle as having an expre

[issue33520] ast.Tuple has wrong col_offset

2018-05-15 Thread R. David Murray
Change by R. David Murray : -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker ___ ___ Python

[issue33520] ast.Tuple has wrong col_offset

2018-05-15 Thread R. David Murray
R. David Murray added the comment: Oh, and the empty tuple is a specific syntactic construct that really is the empty parenthesis, so that's consistent with the language definition. -- ___ Python tracker ___

[issue33520] ast.Tuple has wrong col_offset

2018-05-16 Thread Isaiah Peng
Isaiah Peng added the comment: Fair enough, thanks for clarification. -- ___ Python tracker ___ ___ Python-bugs-list mailing list Un