Python: comparing two sets and writing results to a third set
Question: So this is what I have, I think what I'm looking for is pretty straight-
forward. I want to be able to take the items in set c2 that are not in c1 and
add those to c3. Sets c1 and c2 populate correctly. Any help is appreciated.
Thanks.

    
    
    import csv
    import sys
    c1 = set()
    c2 = set()
    c3 = set()
    
    with open(new, 'r') as newfile:
        newreader = csv.reader(newfile, delimiter=('|'))
        for row in newreader:
            c1.add(row[0])
    
    with open(new, 'r') as oldfile:
        oldreader = csv.reader(oldfile, delimiter=('|'))
        for row in oldreader:
            c2.add(row[0])
    
    for item in c2:
        if item not in c1:
            c3.add(item)
    
    print(c1)
    print(c2)
    print(c3)
    


Answer: try:

    
    
    c3 = c2 - c1
    

its that easy.

Or even:

    
    
    c3 |= c2 - c1
    

if c3 already has some content.

See: <https://docs.python.org/2/library/sets.html>

