PEP Parade
Roman Suzi
rnd at onego.ru
Fri Mar 8 08:48:28 EST 2002
On Fri, 8 Mar 2002, Skip Montanaro wrote:
>
> Roman> Just one comment about
>
> Roman> PEP 270 - uniq method for list objects
>
> Roman> maybe adding dict <-> list conversion functions will make this
> Roman> automatically?
>
>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]
Wow. Then I am a bit underinformed. What uniq is for then?
To cover lengthy:
def uniq(x):
return dict(map(None, x, [None])).keys()
?
:-)
OK, uniq is convenient, I agree. But then other set operations
should follow.
d.update(d1) # d = d + d1
??? # d = d * d1
??? # d = d - d1
(i know it's easy to make class for them, but
so is for uniq)
Sincerely yours, Roman Suzi
--
_/ Russia _/ Karelia _/ Petrozavodsk _/ rnd at onego.ru _/
_/ Friday, March 08, 2002 _/ Powered by Linux RedHat 6.2 _/
_/ "People are always available for work in the past tense." _/
More information about the Python-list
mailing list