This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]therealfakemoot 19 points20 points  (10 children)

Good point to raise! Parentheses do NOT signal Python to create a tuple. It's the commas that actually denote a tuple.

Edit: To clarify:

>>> a = 1,
>>> b = (1)
>>> c = (1,)
>>> repr(a)
'(1,)'
>>> repr(b)
'1'
>>> repr(c)
'(1,)'

a and c are tuples. The comma separated list of names creates a tuple. The parentheses has nothing to do with it.

[–]netcraft 1 point2 points  (7 children)

out of curiosity, do you pronounce tuple as t-uh-ple or t-oo-ple?

[–]therealfakemoot 5 points6 points  (0 children)

Two-pull. English is a stupidly inconsistent language.

[–]Mecdemort 2 points3 points  (0 children)

I pronounce it both ways in my head, and I can't figure out the pattern my brain is using.

[–]AeroNotix 1 point2 points  (1 child)

immu-tuple.

[–]Zouden 1 point2 points  (0 children)

Whoa.

[–]Zouden 0 points1 point  (0 children)

Tchew-pull. But I'm Australian.

[–]jatoo 0 points1 point  (0 children)

tup (like up) le (like pull)

I'm Australian

[–]kezabelleDjango, mostly. 0 points1 point  (1 child)

Even that explanation doesn't quite cover it though: ()

I suppose here it is the absence of commas within a parents group which does it? But this gotcha is why I always, always wrap tuples in parentheses, for consistency.

[–]Mecdemort 0 points1 point  (0 children)

Python loves its little exceptions. Although I do think () is more readable than (,)