This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author YoSTEALTH
Recipients YoSTEALTH, rhettinger, serhiy.storchaka
Date 2016-08-25.21:59:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1472162376.32.0.48589492718.issue27852@psf.upfronthosting.co.za>
In-reply-to
Content
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!
History
Date User Action Args
2016-08-25 21:59:36YoSTEALTHsetrecipients: + YoSTEALTH, rhettinger, serhiy.storchaka
2016-08-25 21:59:36YoSTEALTHsetmessageid: <1472162376.32.0.48589492718.issue27852@psf.upfronthosting.co.za>
2016-08-25 21:59:36YoSTEALTHlinkissue27852 messages
2016-08-25 21:59:35YoSTEALTHcreate