YoSTEALTH added the comment:

Currently there is flatten() function in itertools Recipes section. This is 
what it does:
-> a = ['one', 'plus', [b'two', b'three'], ['four', ('five', (1, {'e', 'ee'}, 
(2, (3, ))), ['six'])], generator()]
<- ['o', 'n', 'e', 'p', 'l', 'u', 's', b'two', b'three', 'four', ('five', (1, 
{'ee', 'e'}, (2, (3,))), ['six']), 0, 1, 2]

As you can see it only flattens 1 nested level and for some reason it explodes 
the 'one' and 'plus' str items (maybe intentionally designed or lazily ignored, 
i don't know).

This is useful maybe in special circumstances where you have:
-> a = [[1, 2, 3], ['one', 'two', 'three']]
<- [1, 2, 3, 'one', 'two', 'three']

Also it doesn't work with bytearray, memoryview ...


In real worldly use something like flatten_all() is more useful!

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue27852>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to