Skip to content

Commit 09a10ce

Browse files
srittaumingyu.park
authored and
mingyu.park
committed
Update an itertool recipe from Python docs (python#13543)
1 parent 0b39a95 commit 09a10ce

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

stdlib/@tests/test_cases/itertools/check_itertools_recipes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ def unique_justseen(iterable: Iterable[_T], key: Callable[[_T], bool] | None = N
284284
"List unique elements, preserving order. Remember only the element just seen."
285285
# unique_justseen('AAAABBBCCDAABBB') --> A B C D A B
286286
# unique_justseen('ABBcCAD', str.lower) --> A B c A D
287+
if key is None:
288+
return map(operator.itemgetter(0), groupby(iterable))
287289
g: groupby[_T | bool, _T] = groupby(iterable, key)
288290
return map(next, map(operator.itemgetter(1), g))
289291

0 commit comments

Comments
 (0)