[DONE] dictionary unpacking (PEP 448)

Hey folks!

PEP 448 added a really neat way to join dictionaries to Python 3.5 using dictionary unpacking, but it seems it’s not implemented in Skulpt, and throws an internal error. Can we catch this and serve a more helpful error message instead?

Exemplified in: https://anvil.works/build#clone:6HZAK44XOWCE32CF=IJSET3NLZM275MAND36JDV5J

1 Like

Thanks for raising.

We should just make this work :wink:

Added to the list.

Oh, BTW, in case anyone tried this and failed, you can still merge dictionaries on a single line.

merged_dict = dict(dict_a, **dict_b)
2 Likes

This has now been done and should work client side.

>>> dict_a = {'a': 1}
>>> dict_b = {'a': 2, 'b': 3}
>>> {**dict_a, **dict_b}
{'a': 2, 'b': 3}

Another related feature on the client side that also works is pep584:

>>> dict_a = {'a': 1}
>>> dict_a |= {'a': 2, 'b': 3} # equivalent to dict_a.update(dict_b)
>>> dict_a
{'a': 2, 'b': 3}

>>> dict_a = {'a': 1} | {'a': 2, 'b': 3} # equivalent to dict(dict_a, **dict_b)
>>> dict_a
{'a': 2, 'b': 3}

linking:

ExternalError: TypeError: a is null caused by Skulpt?

5 Likes