summaryrefslogtreecommitdiffstats
path: root/Doc/library/itertools.rst
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2009-03-22 17:22:36 (GMT)
committerBenjamin Peterson <benjamin@python.org>2009-03-22 17:22:36 (GMT)
commitdb08306bc2f170921e58f0edfd158bae05926c18 (patch)
treec8812c10634e087895f3dab19c16c08d6a8c0f09 /Doc/library/itertools.rst
parent9d57ccb6c66f67c1884173253115d3ec9e9116b5 (diff)
downloadcpython-db08306bc2f170921e58f0edfd158bae05926c18.zip
cpython-db08306bc2f170921e58f0edfd158bae05926c18.tar.gz
cpython-db08306bc2f170921e58f0edfd158bae05926c18.tar.bz2
fix incorrect merge
Diffstat (limited to 'Doc/library/itertools.rst')
-rw-r--r--Doc/library/itertools.rst46
1 files changed, 23 insertions, 23 deletions
diff --git a/Doc/library/itertools.rst b/Doc/library/itertools.rst
index aa133bb..6a4a2a5 100644
--- a/Doc/library/itertools.rst
+++ b/Doc/library/itertools.rst
@@ -683,26 +683,26 @@ which incur interpreter overhead.
s = list(iterable)
return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
- def unique_everseen(iterable, key=None):
- "List unique elements, preserving order. Remember all elements ever seen."
- # unique_everseen('AAAABBBCCDAABBB') --> A B C D
- # unique_everseen('ABBCcAD', str.lower) --> A B C D
- seen = set()
- seen_add = seen.add
- if key is None:
- for element in iterable:
- if element not in seen:
- seen_add(element)
- yield element
- else:
- for element in iterable:
- k = key(element)
- if k not in seen:
- seen_add(k)
- yield element
-
- def unique_justseen(iterable, key=None):
- "List unique elements, preserving order. Remember only the element just seen."
- # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B
- # unique_justseen('ABBCcAD', str.lower) --> A B C A D
- return map(next, imap(itemgetter(1), groupby(iterable, key)))
+ def unique_everseen(iterable, key=None):
+ "List unique elements, preserving order. Remember all elements ever seen."
+ # unique_everseen('AAAABBBCCDAABBB') --> A B C D
+ # unique_everseen('ABBCcAD', str.lower) --> A B C D
+ seen = set()
+ seen_add = seen.add
+ if key is None:
+ for element in iterable:
+ if element not in seen:
+ seen_add(element)
+ yield element
+ else:
+ for element in iterable:
+ k = key(element)
+ if k not in seen:
+ seen_add(k)
+ yield element
+
+ def unique_justseen(iterable, key=None):
+ "List unique elements, preserving order. Remember only the element just seen."
+ # unique_justseen('AAAABBBCCDAABBB') --> A B C D A B
+ # unique_justseen('ABBCcAD', str.lower) --> A B C A D
+ return map(next, map(itemgetter(1), groupby(iterable, key)))