I'm doing some set operations in Python, and I noticed something odd..
>> set([1,2,3]) | set([2,3,4])
set([1, 2, 3, 4])
>> set().union(*[[1,2,3], [2,3,4]])
set([1, 2, 3, 4])
That's good, expected behaviour - but with intersection:
>> set([1,2,3]) & set([2,3,4])
set([2, 3])
>> set().intersection(*[[1,2,3], [2,3,4]])
set([])
Am I losing my mind here? Why isn't set.intersection() operating as I'd expect it to?
How can I do the intersection of many sets as I did with union (assuming the [[1,2,3], [2,3,4]]
had a whole bunch more lists)? What would the "pythonic" way be?