Skip to content

Commit 5bd6a79

Browse files
committed
Python 3 preparation: use sum() instead of reduce().
reduce() has changed from a built-in function to something in functools in Python 3. However, since both uses were with operator.add / operator.__add__, it seemed to make more sense to use sum() instead of functools.reduce().
1 parent 2e0c8ba commit 5bd6a79

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

roundup/cgi/PageTemplates/MultiMapping.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def get(self, key, default=_marker):
1717
raise KeyError(key)
1818
return default
1919
def __len__(self):
20-
return reduce(operator.add, [len(x) for x in self.stores], 0)
20+
return sum([len(x) for x in self.stores])
2121
def push(self, store):
2222
self.stores.append(store)
2323
def pop(self):

tools/pygettext.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ def write(self, fp):
467467
# If the entry was gleaned out of a docstring, then add a
468468
# comment stating so. This is to aid translators who may wish
469469
# to skip translating some unimportant docstrings.
470-
if reduce(operator.__add__, v.values()):
470+
if sum(v.values()):
471471
isdocstring = 1
472472
# k is the message string, v is a dictionary-set of (filename,
473473
# lineno) tuples. We want to sort the entries in v first by

0 commit comments

Comments
 (0)