title: Python: globals().items() iterations try to change a dict
body: <p>In <code>cso.data.__init__.py</code> I'm trying to do following:</p>
  
  <pre><code>from  cso.data._features  import * # import sumbodule 
  
  for k, v in globals().items():
      if isinstance(v, entity):# entity is some type
          print(k,v)
  </code></pre>
  
  <p>To my surprise, I get: </p>
  
  <pre><code>Traceback (most recent call last):
    File "X:\Programming\workspaceEclipse\PyCommonSence\src\cso\data\__init__.py", line 20, in &lt;module&gt;
      from  cso.data._features  import *
    File "X:\Programming\workspaceEclipse\PyCommonSence\src\cso\data\__init__.py", line 49, in &lt;module&gt;
      for k, v in globals().items():
  RuntimeError: dictionary changed size during iteration
  </code></pre>
  
  <p>For some reason it tries to modify the iterated globals somehow. How can it be ?
  Is there another better way to list all variables in the form <code>name: value</code> from all modules in the package?</p>
  
  <p>The list comprehension equivalent works without error, but prints twice:</p>
  
  <pre><code>print([ (k, v) for k, v in globals().items() if isinstance(v, entity)])
  </code></pre>
  
  <p>What is happening here?</p>