Luke Paireepinart wrote:
> 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]
>
> [accessed at
> http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/204297 ]
The problems with this are, it is not
Dick Moores wrote:
> At 09:53 PM 12/6/2006, Luke Paireepinart wrote:
>> # 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]
Because the other methods (via
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.so
I'm new to programming, and trying to learn the Python language.
The following code does what I want it to do, but I have not idea how it
works.
def scanList(names,temp):
for i in names:
temp[i] = 0
print temp
Names = []
temp = {}
I have a list of names (Names[]) and want to
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Morpheus
> Sent: Wednesday, December 06, 2006 9:00 AM
> To: tutor@python.org
> Subject: [Tutor] List to dictionary question
>
> I'm new to programming, and trying
I'm new to programming, and trying to learn the Python language.
The following code does what I want it to do, but I have not idea how it
works.
def scanList(names,temp):
for i in names:
temp[i] = 0
print temp
Names = []
temp = {}
I have a list of names (Names[]) and want to