output.append(input)
return
+ complete_assignments = [rhs]
+
rhs_size = len(rhs.args)
lhs_targets = [ [] for _ in range(rhs_size) ]
starred_assignments = []
if not lhs.is_sequence_constructor:
if lhs.is_starred:
error(lhs.pos, "starred assignment target must be in a list or tuple")
- output.append([lhs,rhs])
+ complete_assignments.append(lhs)
continue
lhs_size = len(lhs.args)
starred_targets = sum([1 for expr in lhs.args if expr.is_starred])
for targets, expr in zip(lhs_targets, lhs.args):
targets.append(expr)
+ if len(complete_assignments) > 1:
+ output.append(complete_assignments[::-1])
+
# recursively flatten partial assignments
for cascade, rhs in zip(lhs_targets, rhs.args):
if cascade:
-__doc__ = """
- >>> simple()
- (1, 2, [1, 2], [1, 2])
- >>> extended()
- (1, (), 2, [1, 2], [1, 2])
-"""
def simple():
+ """
+ >>> simple()
+ ([1, 2], [1, 2])
+ """
+ d = e = [1,2]
+ return d, e
+
+def simple_parallel():
+ """
+ >>> simple_parallel()
+ (1, 2, [1, 2], [1, 2])
+ """
a, c = d = e = [1,2]
return a, c, d, e
def extended():
+ """
+ >>> extended()
+ (1, [], 2, [1, 2], [1, 2])
+ """
a, *b, c = d = e = [1,2]
return a, b, c, d, e