flexxui / pscript

Python to JavaScript compiler
http://pscript.readthedocs.io
BSD 2-Clause "Simplified" License
260 stars 25 forks source link

Reverse argument assignment order #30

Open Winand opened 6 years ago

Winand commented 6 years ago

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.