Tuple Format?

Martijn Faassen m.faassen at vet.uu.nl
Tue Sep 5 09:38:09 EDT 2000


Grant Edwards <nobody at nowhere.nohow> wrote:
> In article <03092000.2 at sanctum.local.jae.ddns.org>, Jürgen A. Erhard wrote:
[snip]
>>PS: I had just learned that "parens don't build tuples, commas build
>>tuples", then you folks come along and get me back to square one.  The
>>tuple syntax is a bigger crock  than I thought.

> It's not that bad unless you think about it too much.

Agreed! So let's think about it some more. :)

> I suspect that most people always use parens around tuples (and probably
> think they have to unless you actually pin them down and make them think
> about it). 

I tend to use parens around tuples frequently, but not always:

a, b = b, a

x, y, z = foo()

And so on. I don't tend to use parens in the context of tuple unpacking,
but elsewhere, I do. Partially because in those contexts I tend to *need*
parens to disambiguate:

def foo(1, 2) versus def foo((1, 2))
[1, 2] versus [(1, 2)]

Regards,

Martijn
-- 
History of the 20th Century: WW1, WW2, WW3?
No, WWW -- Could we be going in the right direction?



More information about the Python-list mailing list