add doctests for pairwise(iter)

This commit is contained in:
Stefan Kögl
2013-07-06 11:17:30 +02:00
parent a3982e34ca
commit 5b7009085a

View File

@@ -223,7 +223,17 @@ class JsonPointer(object):
def pairwise(iterable): def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..." """ s -> (s0,s1), (s1,s2), (s2, s3), ...
>>> list(pairwise([]))
[]
>>> list(pairwise([1]))
[]
>>> list(pairwise([1, 2, 3, 4]))
[(1, 2), (2, 3), (3, 4)]
"""
a, b = tee(iterable) a, b = tee(iterable)
for _ in b: for _ in b:
break break