Skip to content

Commit 0cb0e85

Browse files
Add unit tests for flatten and iflatten in utils.py (#331)
1 parent fd183dd commit 0cb0e85

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

parsel/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ def flatten(x: Iterable[Any]) -> list[Any]:
2929

3030
def iflatten(x: Iterable[Any]) -> Iterator[Any]:
3131
"""iflatten(sequence) -> Iterator
32-
Similar to ``.flatten()``, but returns iterator instead"""
32+
Similar to ``.flatten()``, but returns iterator instead
33+
Examples:
34+
>>> list(iflatten([[1, 2], (3, 4)]))
35+
[1, 2, 3, 4]
36+
"""
3337
for el in x:
3438
if _is_listlike(el):
3539
yield from flatten(el)

0 commit comments

Comments
 (0)