Message273683
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! |
|
Date |
User |
Action |
Args |
2016-08-25 21:59:36 | YoSTEALTH | set | recipients:
+ YoSTEALTH, rhettinger, serhiy.storchaka |
2016-08-25 21:59:36 | YoSTEALTH | set | messageid: <1472162376.32.0.48589492718.issue27852@psf.upfronthosting.co.za> |
2016-08-25 21:59:36 | YoSTEALTH | link | issue27852 messages |
2016-08-25 21:59:35 | YoSTEALTH | create | |
|