Did I find the right examples for you? yes no Crawl my project Python Jobs
All Samples(3) | Call(2) | Derive(0) | Import(1)
def flatten_deep(x): result = [] for el in x: if hasattr(el, "__iter__") and not isinstance(el, basestring): result.extend(flatten_deep(el)) else: result.append(el) return result
self.assertListEqual(flatten([]), []) from list115utils import flatten_deep class TestFlattenDeep(TestListUtils): def test_flatten_deep_works_on_mixed_deep_lists(self): l = ['a', ['1', ['apple', 'orange'], [], '3'], [4,5,6], [], 'b'] self.assertListEqual(flatten_deep(l), ['a', '1', 'apple', 'orange', '3', 4, 5, 6, 'b']) def test_flatten_deep_works_on_empty_list(self): self.assertListEqual(flatten_deep([]), [])