Re: finding the intersection of a list of Sets
- From: "Raymond Hettinger" <python@xxxxxxx>
- Date: 31 Jan 2006 08:31:05 -0800
[Peter Otten]
> >>> sets = map(set, "abc bcd cde".split())
> >>> reduce(set.intersection, sets)
> set(['c'])
Very nice. Here's a refinement:
>>> sets.sort(key=len)
>>> reduce(set.intersection, sets[1:], sets[0])
set(['c'])
.
- Follow-Ups:
- Re: finding the intersection of a list of Sets
- From: Raymond Hettinger
- Re: finding the intersection of a list of Sets
- References:
- finding the intersection of a list of Sets
- From: Suresh Jeevanandam
- Re: finding the intersection of a list of Sets
- From: Peter Otten
- finding the intersection of a list of Sets
- Prev by Date: Re: simple perl program in python gives errors
- Next by Date: Re: templates
- Previous by thread: Re: finding the intersection of a list of Sets
- Next by thread: Re: finding the intersection of a list of Sets
- Index(es):