title: How to loop through a set, while removing items from the set in Python 3
body: <p>Here is my situation:</p>
  
  <p>I have a <code>list/set</code> (doesn't matter which) of <code>movieplayer</code> objects that I want to call a <code>"preload"</code> function on.  This preload function could return immediately but would like return a bit in the future.</p>
  
  <p>I want to store this collection of movieplayers, indicating that they have not been preloaded yet, then loop through them, calling the <code>preload</code> function.  The <code>preload</code> function, when returned, would remove them from the collection (so I would know when they are all preloaded).  </p>
  
  <p>However, I think because python is waiting for the <code>preload</code> function, then removing the player, I am getting a <code>set size changed during iteration error</code>.  </p>
  
  <p>Hey is a simplified version of my code, I would appreciate a way to navigate this issue.</p>
  
  <pre><code>a = set([mp1, mp2 mp3])
  for player in a:
      preload(player)
  
  # preload would be something like
  def preload(player):
      player.preloadVideo()
      a.remove(player)
      # This is where I believe the error gets generated.
  </code></pre>
  
  <p>The only solution that I can think of would be to make a <code>copy</code> of the <code>set a</code>, and then iterate through that, but I am not sure if that is the right way to do it or would even work.</p>