def _partition(obj): for s in flatten(obj): head, sep, tail = s.partition(separator) if normalize_head: head = normalize_head(head) if normalize_tail: tail = normalize_tail(tail) if sep: yield (head, tail)
def test_flatten(): assert list(i.flatten([['a'], ['b']])) == ['a', 'b']
def test_flatten_nested(): assert list(i.flatten([['a'], ['b', 'c']])) == ['a', 'b', 'c']
def test_flatten_string(): # A string isn't considered iterable so nothing should happen assert list(i.flatten('abc')) == ['abc']