import sys

class Set(dict):
    def __init__(self, t=[]):
        for item in t:
            self[item] = 1

    def intersect(self, other):
        res = Set()
        for key in self:
            if key in other:
                res[key] = 1
        return res

    def union(self, other):
        res = Set(self)
        res.update(other)   
        return res

    __add__ = union
    __xor__ = intersect

    def __str__(self):
        return str(self.keys())
    
def main(*args):
    s1 = Set(range(3))
    s2 = Set([3, 2, 1])
    s3 = Set('allen')

    print s1
    print s2
    print s3
    print s1.intersect(s2)
    print s1^s2
    print s1.union(s2)
    print s1+s2
    
if __name__ == '__main__':
    main(*sys.argv)
