pscript icon indicating copy to clipboard operation
pscript copied to clipboard

Reverse argument assignment order

Open Winand opened this issue 7 years ago • 0 comments

Fixes #23 Problem:

def partial2(a1, a2, *args, **kwargs):
    print(a1, a2)
    print(args)
    print(kwargs)

The original order of assignment is **kwargs, a1, a2, *args. But after assigning a1 (which is arguments[0]) we cannot get more arguments.

Solution: Assign everything in reverse order: **kwargs, *args, a2, a1. So we "break" arguments[0] at the very end when we don't need it anymore.

Winand avatar Oct 03 '18 17:10 Winand