+ 2

How importing "flatten" library in python 3.7.0

In python 2.7 is just import flatten but 3.7.0 is different

15th Mar 2019, 10:43 AM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
3 Respuestas
+ 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
16th Mar 2019, 5:31 PM
Eliya Ben Baruch
Eliya Ben Baruch - avatar
+ 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
15th Mar 2019, 5:58 PM
Tibor Santa
Tibor Santa - avatar
16th Mar 2019, 6:36 PM
Tibor Santa
Tibor Santa - avatar