Skip to content

Commit

Permalink
Add some more boundary conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Mar 28, 2019
1 parent f107221 commit a24139c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions jaraco/itertools.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,20 @@ def takewhile_peek(predicate, iterable):
>>> empty = takewhile_peek(is_small, Peekable([]))
>>> list(empty)
[]
>>> items = Peekable([3])
>>> small_items = takewhile_peek(is_small, items)
>>> list(small_items)
[3]
>>> list(items)
[]
>>> items = Peekable([4])
>>> small_items = takewhile_peek(is_small, items)
>>> list(small_items)
[]
>>> list(items)
[4]
"""
while True:
if not predicate(iterable.peek()):
Expand Down

0 comments on commit a24139c

Please sign in to comment.