title: Unexplained variables in global namespace
body: <p>I'm finding that if I don't assign the returned value of a function to variable, it still ends up in the global namespace. To re-create the situation in miniature, I've created a test class, and a function that returns an instance of that class:</p>
  
  <pre><code>class testclass:
      def __init__(self):
          pass
  
  def test_func():
      return testclass()
  </code></pre>
  
  <p>I've then created a function to count how many of these variables are in the global namespace:</p>
  
  <pre><code>def count_tc(glob):
      num = 0
      for name, obj in glob.items():
          if isinstance(obj, testclass):
              print(name)
              num+=1
      return num
  </code></pre>
  
  <p>if I run this count_tc function initially, it returns 0. But if I run test_func then re-run it, I get:</p>
  
  <pre><code>test_func()
  count_tc(globals())
  </code></pre>
  
  <p>Returning</p>
  
  <pre><code>_
  _8
  2
  </code></pre>
  
  <p>So we now have not one but two variables in the global namespace that seem to have been assigned _ type names.</p>
  
  <p>My understanding of the garbage collection process in python is that if there are no references to an object, it gets deleted - so I'd expect that to happen in this case. This is a toy example but I have it going on somewhere else where memory is an issue and it seems to be creating problems.
  Could anyone enlighten me as to what is (or what is meant to be) happening here? I'm not sure if this is relevant but I'm running this in Jupyter notebook.
  Thanks!</p>