Skip to content

Commit f2c8c50

Browse files
author
Thomas Preud'homme
committed
[LNT] Python 3 support: adapt to zip returning an iterator
Summary: zip() returns a list in Python 2 but an iterator in Python 3. Fortunately, the only use is in the return statement in pairs() and the only call site of pairs() iterates over the result. This commit thus adds a docstrings for pairs to make it clear callers can only rely on the result being iterable. It also rename the parameter to not conflict with the list builtin function. Reviewers: cmatthews, hubert.reinterpretcast, kristof.beyls Reviewed By: hubert.reinterpretcast Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D67819 llvm-svn: 372826
1 parent 87fade3 commit f2c8c50

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lnt/server/reporting/report.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@
88

99
OrderAndHistory = namedtuple('OrderAndHistory', ['max_order', 'recent_orders'])
1010

11-
def pairs(list):
12-
return zip(list[:-1], list[1:])
11+
def pairs(l):
12+
"""Make an iterable of all pairs of consecutive elements in l."""
13+
return zip(l[:-1], l[1:])
1314

1415
# The hash color palette avoids green and red as these colours are already used
1516
# in quite a few places to indicate "good" or "bad".

0 commit comments

Comments
 (0)