Post #2031800
2026-04-28 11:07 UTC
oo neat, unpacking in list comprehensions, nicer way to flatten nested lists
before:
[item for sublist in nestedlists for item in sublist]
after:
[*sublist for sublist in nestedlist]
https://docs.python.org/3.15/whatsnew/3.15.html#whatsnew315-unpacking-in-comprehensions
#python
Replies (4)
-
@hynek@mastodon.social 2026-04-28 12:52
@hjwp@fosstodon.org finally a syntax i can fucking remember 🥲
-
@ghickman@mastodon.social 2026-04-28 13:33
@hjwp@fosstodon.org clearer than chain.from_iterable() too 🎉
-
@iris@neuromatch.social 2026-04-28 14:49
@hjwp@fosstodon.org for some reason I can install up to python 3.14 with miniconda but it fails on 3.15 even when I specify 3.15.0a8, per the instructions on conda-forge. I just want to know when **nestedlist works.
-
@feoh@oldbytes.space 2026-04-28 15:44
@hjwp@fosstodon.org OOH new syntax that actually makes things more readable and easier to understand. LOVE this! <3 <3 <3