The Python Oracle

Flatten an irregular (arbitrarily nested) list of lists

Become part of the top 3% of the developers by applying to Toptal https://topt.al/25cXVn

--

Track title: CC F Haydns String Quartet No 53 in D

--

Chapters
00:00 Question
01:11 Accepted answer (Score 460)
02:05 Answer 2 (Score 66)
02:23 Answer 3 (Score 47)
02:42 Answer 4 (Score 42)
03:14 Thank you

--

Full question
https://stackoverflow.com/questions/2158...

Question links:
[Python idiom to chain (flatten) an infinite iterable of finite iterables?]: https://stackoverflow.com/questions/1208...
[Flattening a shallow list in Python]: https://stackoverflow.com/questions/4061...
[Comprehension for flattening a sequence of sequences?]: https://stackoverflow.com/questions/4572...
[How do I make a flat list out of a list of lists?]: https://stackoverflow.com/questions/9529...
[in this question]: https://stackoverflow.com/questions/4061...

Accepted answer links:
[Iterable]: https://docs.python.org/2/library/collec...
[yield from]: https://docs.python.org/3/whatsnew/3.3.h...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#python #list #optimization #nestedlists #flatten

#avk47