El jue, 17 jun 2021 a las 14:45, David Mertz (<
mertz@gnosis.cx>) escribió:
On Thu, Jun 17, 2021, 5:24 PM Ben Rudiak-Gould
Okay, slightly off-topic, but can we *please* allow
[*chunk for chunk in list_of_lists]
It is completely non-obvious to me what that would even MEAN. I cannot derive anything obvious from other uses of *.
My reading is that it would behave like `[*chunk1, *chunk2, *chunk3]` would behave if `list_of_lists = [chunk1, chunk2, chunk3]`. I would support adding this behavior to Python.
I guess I can kinda see that analogy. But a loop is an assignment, and this doesn't mean "flatten":
a, b, *c = 1, 2, 3, 4, 5, 6
Moreover, in a regular loop:
>>> for *x in [a, b, c]:
... print(x)
File "<ipython-input-13-a22866454ece>", line 1
for *x in [a, b, c]:
^
SyntaxError: starred assignment target must be in a list or tuple
Neither of my examples, I admit, are quite the same as the comprehension. Nonetheless, I definitely don't think the proposed syntax is "the one obvious way to do it."
The dead increasingly dominate and strangle both the living and the
not-yet born. Vampiric capital and undead corporate persons abuse
the lives and control the thoughts of homo faber. Ideas, once born,
become abortifacients against new conceptions.