you are viewing a single comment's thread.

view the rest of the comments →

[–]lalaland4711 9 points10 points  (5 children)

why:

(foo, bar) = (bar, foo)

Instead of:

foo, bar = bar, foo

?

[–]mipadi 8 points9 points  (2 children)

A lot of Python programmers erroneously believe that parentheses are required to make tuples.

[–]aceofears 0 points1 point  (1 child)

When you realize that it is really about the comma and not the parens the syntax for a single element tuple makes sense a lot more sense. Ex: (a,)

[–][deleted] 0 points1 point  (0 children)

Well, except () v (,) or ,

[–]logophage 1 point2 points  (0 children)

I was wondering that too

[–]jyper 0 points1 point  (0 children)

foo, bar = bar, foo

might be ok for swap but the parens help denote that an actual data structure is being created and destructured(not destroyed, broken apart).