Issue5532
Created on 2009-03-21 18:10 by mnewman, last changed 2009-03-22 17:22 by benjamin.peterson.
|
msg83943 - (view) |
Author: Michael Newman (mnewman) |
Date: 2009-03-21 18:10 |
|
The recipe for "unique_justseen" listed on:
http://docs.python.org/3.0/library/itertools.html
uses "imap", which is not available in Python 3.0.
I fixed it by changing "imap" to just "map", and I also changing
"itemgetter" to "operator.itemgetter" to make the namespace usage
clearer in the recipe:
Python 3.0.1 (r301:69561, Feb 13 2009, 20:04:18) [MSC v.1500 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from itertools import *
>>> import operator
>>> 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(operator.itemgetter(1), groupby(iterable,
key)))
...
>>> unique_justseen('AAAABBBCCDAABBB')
<map object at 0x00BB2690>
>>> list(unique_justseen('AAAABBBCCDAABBB'))
['A', 'B', 'C', 'D', 'A', 'B']
>>> unique_justseen('ABBCcAD', str.lower)
<map object at 0x00BB2650>
>>> list(unique_justseen('ABBCcAD', str.lower))
['A', 'B', 'C', 'A', 'D']
>>>
|
|
msg83949 - (view) |
Author: Raymond Hettinger (rhettinger) |
Date: 2009-03-21 19:15 |
|
Benjamin, please revert r69354 which was an incorrect merge.
|
|
msg83976 - (view) |
Author: Benjamin Peterson (benjamin.peterson) |
Date: 2009-03-22 17:22 |
|
Done in r70520.
|
|
| Date |
User |
Action |
Args |
| 2009-03-22 17:22:50 | benjamin.peterson | set | status: open -> closed resolution: fixed messages:
+ msg83976
|
| 2009-03-21 19:15:19 | rhettinger | set | assignee: rhettinger -> benjamin.peterson
messages:
+ msg83949 nosy:
+ benjamin.peterson |
| 2009-03-21 18:44:51 | benjamin.peterson | set | assignee: georg.brandl -> rhettinger
nosy:
+ rhettinger |
| 2009-03-21 18:10:44 | mnewman | create | |
|