MCPcopy Create free account
hub / github.com/django/code.djangoproject.com / tripletwise

Function tripletwise

noshadows.py:32–45  ·  view source on GitHub ↗

Like itertools.pairwise, but for triplets instead of pairs.

(iterable)

Source from the content-addressed store, hash-verified

30
31
32def tripletwise(iterable): # no relation to Jeff
33 """
34 Like itertools.pairwise, but for triplets instead of pairs.
35 """
36 i = iter(iterable)
37 try:
38 x, y, z = next(i), next(i), next(i)
39 except StopIteration:
40 return
41
42 yield x, y, z
43 for el in i:
44 x, y, z = y, z, el
45 yield x, y, z
46
47
48def skip_whitespace(nodes):

Callers 3

has_shadowFunction · 0.85
test_tripletwiseMethod · 0.85

Calls

no outgoing calls

Tested by 2

test_tripletwiseMethod · 0.68