I have a set myset, and I have a function which iterates over it to perform some operation on its items and this operation ultimately deletes the item from the
myset
This ought to work:
while myset: item = myset.pop() # do something
Or, if you need to remove items conditionally:
def test(item): return item != "foo" # or whatever myset = set(filter(test, myset))