def __contains__(self, item):
    'Override to stop on encountering items.'
    if (item in self.stop_list):
        raise StopIteration
    else:
        return super(ContainsStopList, self).__contains__(item)
Override to stop on encountering items.
def __contains__(self, item):
    
    if (item in self.stop_list):
        raise StopIteration
    else:
        return super(ContainsStopList, self).__contains__(item)