I want to do this:

(apply nconc ref)

but in #Python 3.8.

So I wrote this:

[i for j in ref for i in j].

Is this idiomatic? Is there any suggestion?

@veer66 can't say how widely it's used, but it is indeed how I usually flatten "sequence of sequences". There's also moreitertools.flatten if you don't mind a dependency. github.com/erikrose/more-itert

Follow

@isagalaev @veer66 how is flatten different from iterttols.chain.from_iterable?

Sign in to participate in the conversation
3dots.lv Mastodon Instance

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!