.. getthecode:: unpacking.py :language: python3 :hidden: =========== Unpacking =========== This page contains a memo on unpacking. `PEP 448 - Additional Unpacking Generalizations `_ .. code-block:: py3 _= *[1], *[2], 3, *[4, 5] print(_) .. code-block:: none (1, 2, 3, 4, 5) .. code-block:: py3 def fn(a, b, c, d): print(a, b, c, d) fn(**{'a': 1, 'c': 3}, **{'b': 2, 'd': 4}) .. code-block:: none 1 2 3 4 .. code-block:: py3 _ = *range(4), 4 print(_) _ = [*range(4), 4] print(_) _ = {*range(4), 4, *(5, 6, 7)} print(_) _ = {'x': 1, **{'y': 2}} print(_) .. code-block:: none (0, 1, 2, 3, 4) [0, 1, 2, 3, 4] {0, 1, 2, 3, 4, 5, 6, 7} {'x': 1, 'y': 2}