News for hackers. Stuff that matters.
Re:Learn Python in minutes by xutopia on Friday June 28, 2013 @04:17PM (#5960122)
What does he mean by "# Tuples are created by default if you leave out the parentheses".

With or without the parens I'm getting the same result for "a, b, c = (1, 2, 3)"

Re:Learn Python in minutes by eurleif on Friday June 28, 2013 @04:21PM (#5960144)
Yes, that is the same with or without parentheses. You're creating a tuple on the right-hand side of the equal sign, and using tuple unpacking on the left-hand side to assign the members of that tuple to variables. To make it a bit more clear, you can add parentheses on the left to match the ones on the right:

    (a, b, c) = (1, 2, 3)
Re:Learn Python in minutes by madelfio on Friday June 28, 2013 @04:36PM (#5960227)
You get a list if you do "object_a = [1, 2, 3]" and a tuple if you do "object_b = (1, 2, 3)". Then try "object_c = 1, 2, 3" and you'll also get the tuple.
Re:Learn Python in minutes by cben on Tuesday July 02, 2013 @06:37PM (#5981190)
You should also mention the 1-item case where the (optional in other cases) trailing comma is required to form a tuple: (1,)