Re: Tuples
Posted: Mon Jun 24, 2013 4:27 pm
That's right about Python not requiring parens. Though I wouldn't be opposed to requiring them outside of "return" and assignment. I'm trying to think of other places in Python where they are not required. If you want to pass them as arguments, they certainly need parens:
Btw the funny syntax that hopscc was thinking of comes into play when your tuple has only one element:
Without a trailing comma, it would not be a tuple.
- Code: Select all
# python
obj.foo((1, 2), (2, 1)) # 2 arguments, each a tuple of two ints
obj.foo(1, 2, 2, 1) # 4 arguments, each an int
Btw the funny syntax that hopscc was thinking of comes into play when your tuple has only one element:
- Code: Select all
# python
t = (1,)
Without a trailing comma, it would not be a tuple.