Open tomkcook opened 1 year ago
There must be an edge case somewhere in the compiler. With a slightly simpler example, this works:
def test(args):
print(list(args.keys()))
test(dict(**{'class': 'my-class'}))
But this does not:
def test(args):
print(list(args.keys()))
test({**{'class': 'my-class'}})
Though both versions work in CPython.
Those last two examples are actually significantly different at the technical/language level, and the latter is actually a lot newer in CPython.
dict(**a_dictionary)
is a splatting a dictionary into arguments of a function call. In Python since 2.2 (over 20 years ago).{**a_dictionary}
is splatting a dictionary into a dictionary If I had to guess, Transcrypt has different code paths for "translating the stuff inside a function call" and "translating the stuff inside a dictionary display", and the former is expecting the possibility of a **
while the latter isn't.
Example:
Transcrypt output:
The dictionary unpack is obviously redundant in this case but is useful in more complex cases.