Unpacking in list, dict, set, and tuple literals has been added in Python 3.5
, as described in PEP 448:
Python 3.5.0 (v3.5.0:374f501f4567, Sep 13 2015, 02:27:37) on Windows (64 bits).
>>> [1, 2, 3, *[4, 5, 6]]
[1, 2, 3, 4, 5, 6]
Here are some explanations for the rationale behind this change. Note that this does not make *[1, 2, 3]
equivalent to 1, 2, 3
in all contexts. Python’s syntax is not intended to work that way.