4 ms·
It's the comma that determines an expression as a tuple, not the parentheseis.
by rnnr 12y ago
It's the comma that determines an expression as a tuple, not the parentheseis.
- lucian1900 12y agoWhich is the source of the original problem, which I've also encountered myself.
- yeukhon 12y agoThat syntax reminds me of trying to do the following print x, print y But I generall find myself doing the , in the situation like (element1,) to create a new tuple.
- herge 12y agoNot all the time. x = , causes a syntax error, while x = (,) creates an empty tuple.
- dalke 12y agoUnder both Python 2.7 and Python 3.3 I get: >>> x=(,) File "<stdin>", line 1 x=(,) ^ SyntaxError: invalid syntax
- Spittie 12y agoFrom the Python docs (https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences https://docs.python.org/3/tutorial/datastructures.html#tuple...) > Empty tuples are constructed by an empty pair of parentheses; And it works fine >>> x = () >>> x () I guess Herge mean that? After all, his argument was that a tuple is not always defined by the comma.