"vscode:/vscode.git/clone" did not exist on "7e9a9d32c7a9259a1bd57b0b461c36d089d26fe8"
Unverified Commit e4970d81 authored by Yuliang Li's avatar Yuliang Li Committed by GitHub
Browse files

fix: incorrect argument order in `utils.divide` doc (#1208)

parent 8ffbe58a
...@@ -682,7 +682,7 @@ def divide(iterable, n) -> List[Iterator]: ...@@ -682,7 +682,7 @@ def divide(iterable, n) -> List[Iterator]:
"""Divide the elements from *iterable* into *n* parts, maintaining """Divide the elements from *iterable* into *n* parts, maintaining
order. order.
>>> group_1, group_2 = divide(2, [1, 2, 3, 4, 5, 6]) >>> group_1, group_2 = divide([1, 2, 3, 4, 5, 6], 2)
>>> list(group_1) >>> list(group_1)
[1, 2, 3] [1, 2, 3]
>>> list(group_2) >>> list(group_2)
...@@ -691,14 +691,14 @@ def divide(iterable, n) -> List[Iterator]: ...@@ -691,14 +691,14 @@ def divide(iterable, n) -> List[Iterator]:
If the length of *iterable* is not evenly divisible by *n*, then the If the length of *iterable* is not evenly divisible by *n*, then the
length of the returned iterables will not be identical: length of the returned iterables will not be identical:
>>> children = divide(3, [1, 2, 3, 4, 5, 6, 7]) >>> children = divide([1, 2, 3, 4, 5, 6, 7], 3)
>>> [list(c) for c in children] >>> [list(c) for c in children]
[[1, 2, 3], [4, 5], [6, 7]] [[1, 2, 3], [4, 5], [6, 7]]
If the length of the iterable is smaller than n, then the last returned If the length of the iterable is smaller than n, then the last returned
iterables will be empty: iterables will be empty:
>>> children = divide(5, [1, 2, 3]) >>> children = divide([1, 2, 3], 5)
>>> [list(c) for c in children] >>> [list(c) for c in children]
[[1], [2], [3], [], []] [[1], [2], [3], [], []]
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment