PEP Parade
Raymond Hettinger
python at rcn.com
Fri Mar 8 16:21:45 EST 2002
"Skip Montanaro" <skip at pobox.com> wrote in message
news:mailman.1015592594.15478.python-list at python.org...
>
> Roman> Just one comment about
>
> Roman> PEP 270 - uniq method for list objects
> Nothing new is necessary since 2.2 was released:
>
> >>> mylist = [1,2,3,5,6,6,9,9,1,2,3,4]
> >>> mydict = dict(zip(mylist,mylist))
> >>> mydict
> {1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6, 9: 9}
> >>> mydict.values()
> [1, 2, 3, 4, 5, 6, 9]
Here's a one-liner version that works for all iterables
(using mylist only once):
>>> print map(None, dict(map(None, mylist, (None,))))
[1, 2, 3, 4, 5, 6, 9]
Raymond Hettinger
More information about the Python-list
mailing list