New submission from danijar <m...@danijar.com>:
A tuple can be created with or without parentheses: a = (1, 2, 3) a = 1, 2, 3 While both are intuitive in this example, omitting the parentheses can lead to hard to find errors when there is only one element: a = (1,) a = 1, The first is clear but the second can easily occur as a typo when the programmer actually just wanted to assign an integer (comma is next to enter on many keyboards). I think ideally, omitting parentheses in the single element case would throw a SyntaxError. On the other hand, I assume that it could be difficult to separate the behavior or tuple creating with an without parentheses, since the parentheses are probably not actually part of the tuple literal. ---------- components: Interpreter Core messages: 340298 nosy: benjamin.peterson, brett.cannon, danijar, xtreak, yselivanov priority: normal severity: normal status: open title: Restrict syntax for tuple literals with one element _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue36637> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com