newbie list question

Kamus of Kadizhar yan at NsOeSiPnAeMr.com
Sat Dec 6 06:53:41 EST 2003


I have two lists, fav and oldfav.  Each has the same number of elements. 
  Each is a list of lists:

fav:  [['dcp_0229.jpg', 'dcp_0230.jpg', 'dcp_0231.jpg', 'dcp_0235.jpg', 
'dcp_0237.jpg', 'dcp_0238.jpg', 'dcp_0240.jpg', 'dcp_0243.jpg'], 
['dcp_0244.jpg', 'dcp_0252.jpg', 'dcp_0257.jpg', 'dcp_0275.jpg', 
'dcp_0276.jpg', 'dcp_0280.jpg', 'dcp_0283.jpg', 'dcp_0284.jpg'], 
['dcp_0287.jpg', 'dcp_0293.jpg', 'dcp_0294.jpg', 'dcp_0303.jpg', 
'dcp_0308.jpg', 'dcp_0314.jpg', 'dcp_0319.jpg', 'dcp_0331.jpg'], 
['dcp_0336.jpg', 'dcp_0346.jpg', 'dcp_0347.jpg', 'dcp_0349.jpg', 
'dcp_0350.jpg', 'dcp_0353.jpg', 'dcp_0355.jpg', 'dcp_0360.jpg']]

oldfav:  [['dcp_0278.jpg', 'dcp_0348.jpg', 'dcp_0349.jpg', 
'dcp_0275.jpg', 'dcp_0347.jpg', 'dcp_0318.jpg', 'dcp_0280.jpg', 
'dcp_0315.jpg', 'dcp_0240.jpg'], [], [], []]

I want to remove those elements that are in the sub-lists of fav that 
also appear in the corresponding sub-list of oldfav:

for the 1st sub-list of fav
	difffav[0:1] = Set(fav[0:1]) - Set(oldfav[0:1])
for the 2nd sub-list of fav
	difffav[1:2] = Set(fav[1:2]) - Set(oldfav[1:2])

and so on.

The number of sub-lists in fav and oldfav may change, but they will 
always be the same.

I can hack this up using C-style indexes, but I have to imagine there is 
some neat python way that eliminates indexes altogether.

-Kamus

-- 
What am I on?
I'm on my bike,                         o__
6 hours a day, busting my ass.          ,>/'_
What are you on? --Lance Armstrong     (_)\(_)





More information about the Python-list mailing list