3 ответов
+ 3
Tibor Santa
If you wanna check I already did it in python 2.7 to import the library flatten is:
from compiler.ast import flatten
and in python 3.7 I made a code for that.
Thanks
+ 2
flatten is not standard python, not even in 2.7.
You may write a custom function to flatten a nested list (up to any level) following the idea here:
https://stackoverflow.com/questions/2158395/flatten-an-irregular-list-of-lists
Or you can use chain() or chain.from_iterable() in itertools library
+ 2
Ok, I see. Again I found that compiler.ast is deprecated since python 2.6
https://stackoverflow.com/questions/16176742/python-3-replacement-for-deprecated-compiler-ast-flatten-function