# Pre-PEP: Unpacking in Comprehensions

**URL:** <https://discuss.python.org/t/pre-pep-unpacking-in-comprehensions/96362>\
**Category:** Ideas\
**Created:** [June 22, 2025, 5:51pm UTC](https://discuss.python.org/t/pre-pep-unpacking-in-comprehensions/96362 "2025-06-22T17:51:34Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![blhsing](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/blhsing/32/25812_2.png) [@blhsing](https://discuss.python.org/u/blhsing)\
**Post date:** [June 23, 2025, 1:38am UTC](https://discuss.python.org/t/pre-pep-unpacking-in-comprehensions/96362/7 "2025-06-23T01:38:15Z")

</div>

I’ve always found it surprising and counter-intuitive that unpacking in comprehensions doesn’t work ever since I learned about generalized unpacking in container literals.

That said, I think the PEP needs to address the [concern](https://peps.python.org/pep-0448/#variations) raised by the explanations to why such a feature wasn’t included in PEP-448, specifically that it would cause ambiguity when unpacking in an unbracketed generator expression in a call since argument list already supports unpacking.

That is, which one of these is intended?

```python
f(*x for x in it) == f((*x for x in it))

```

or:

```python
f(*x for x in it) == f(*(x for x in it))

```

Original quote from PEP-448:

> Unbracketed comprehensions in function calls, such as `f(x for x in it)`, are already valid. These could be extended to:
> 
> ```python
> f(*x for x in it) == f((*x for x in it))
> f(**x for x in it) == f({**x for x in it})
> 
> ```
> 
> However, it wasn’t clear if this was the best behaviour or if it should unpack into the arguments of the call to `f`. Since this is likely to be confusing and is of only very marginal utility, it is not included in this PEP. Instead, these will throw a `SyntaxError` and comprehensions with explicit brackets should be used instead.

---

_[View the full topic](https://discuss.python.org/t/pre-pep-unpacking-in-comprehensions/96362)._
