DEV Community

Discussion on: A look at itertools chain method

Collapse
 
waylonwalker profile image
Waylon Walker • Edited

I am a big fan of replacing nested loops with itertools/more itertools. I often use more_itertools.flatten, I was curios what the difference was between flatten and chain.from_iterables so I opened up a repl and found this.

more itertools flatten

I'll argue that flatten is more readable and likely that folks will understand what it is doing intuitively when they read my code, but it comes at the cost of an extra dependency.