Version-Specific Features

Python 3.15 — Unpacking in comprehensions

Starred elements in list, set and generator comprehensions flatten one level of iteration; double-starred dictionary comprehensions merge mappings. Iteration order and duplicate-key replacement follow the corresponding construct. Requires Python 3.15 or the relevant build; example is not executed locally.

Formal Syntax & Structure

python syntaxpython
[*part for part in parts]

Return Value

Feature-specific

No single return type; see the example and feature description.

Working Example

Example Snippetpython
parts = [[1, 2], [3]]print([*part for part in parts])print({**item for item in [{'a': 1}, {'a': 2}]})
Python Reference