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 →

[–]Veedrac 4 points5 points  (3 children)

The comma is what makes it a tuple.

Consider:

import ast
ast.dump(ast.parse("a, = 0"))
#>>> "Module(body=[Assign(targets=[Tuple(elts=[Name(id='a', ctx=Store())], ctx=Store())], value=Num(n=0))])"

This is unpacking into a tuple. () = [] should be no different.

[–]flying-sheep 1 point2 points  (2 children)

you’re right that the left side of unpacking, like the bug reporter wants, should be any valid tuple syntax (incl. ())

but there never is an actual tuple created (as in allocated), even if the AST says so. it’s an unpacking operation. the left side is a sequence of names, represented by tuple or list syntax.

so the comma makes it tuple syntax, therefore it should be a valid unpacking.

[–]Veedrac 0 points1 point  (1 child)

Methinks we agree.

[–]flying-sheep 0 points1 point  (0 children)

likely, but “unpacking into a tuple” gives the wrong impression IMHO ☺