I just had an issue brought up by another developer who had a trailing comma on an assignment causing a 1-tuple he did not expect. We were talking about it and came to the conclusion that it is at least worth bringing up the idea of enforcing a SyntaxError in the case of this. 1-tuple syntax is already an odd-man-out, so requiring more explicitness about it would catch some errors and be more readable. I think we could agree that a tuple of 2 or more elements is much easier to read without parens than a 1-tuple without parens. Aside from assignment I can't think of a single place when one would construct a 1-tuple without parens. This is the offending erroneous and hard-to-catch code: if foo: bar = 3, L = [1, 2, bar] Would there be any possibility in considering further refining the 1- tuple syntax to require parens because of its nature?
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4