Is it possible to remove duplicate records from a list of tuples? Here's a sample of my list. I'd like to make sure a url doesn't occur twice in the list, and delete the offending tuple if it does. [('http://www.news.com/frontdoor/0-1.html?tag=hd_ts', 'CNET'), ('http://www.news.com/shopping/0-1257.html?tag=hd_ts', 'Price comparisons')] I'm sorry if this is elementary, but I'm fairly new to Python and have been pulling my hair out on this one. Thanks, Aaron Gillette abg@comco-inc.com
Pretty easy map={} for x,y in mylist: map[x]=y map.items() It will be in a random order aftward though. And duplicate may depend on the definition of equality, which may not do what you expect.
-----Original Message----- From: zope-admin@zope.org [mailto:zope-admin@zope.org]On Behalf Of abg@comco-inc.com Sent: Friday, July 19, 2002 12:09 PM To: zope@zope.org Subject: [Zope] Dupe checking a list of tuples
Is it possible to remove duplicate records from a list of tuples?
Here's a sample of my list. I'd like to make sure a url doesn't occur twice in the list, and delete the offending tuple if it does.
[('http://www.news.com/frontdoor/0-1.html?tag=hd_ts', 'CNET'), ('http://www.news.com/shopping/0-1257.html?tag=hd_ts', 'Price comparisons')]
I'm sorry if this is elementary, but I'm fairly new to Python and have been pulling my hair out on this one.
Thanks,
Aaron Gillette abg@comco-inc.com
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
participants (2)
-
abg@comco-inc.com -
Charlie Reiman