At 09:53 PM 12/6/2006, Luke Paireepinart wrote: > >> I have a list of names (Names[]) and want to remove duplicate names in > >> the list. [snip] > >> > > > > The way I usually do this is something like: > > > > outDict = dict(map(lambda x: (x, 1), inList)) > > names = outDict.keys() > > names.sort() > > >How about this :D > ># Remove duplicates from a list: > >>> L = [1,2,2,3,3,3] > >>> [x for x in L if x not in locals()['_[1]'].__self__] >[1,2,3]
Why not >>> L = [1,2,2,3,3,3] >>> list(set(L)) [1, 2, 3] ? That's a real question. Dick Moores _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor