title: List user defined variables from a parent module (Python 3)
body: <p>I have a function within a module that lists defined variables</p>
  <p>Simplified Example:</p>
  <pre><code>    for var_name in globals():
          if not var_name.startswith('__'):
              var_value = eval(var_name)
              var_type = type(var_value)
              print(var_name, &quot;is&quot;, var_type, &quot;and is equal to &quot;, var_value)
  </code></pre>
  <p>This works when I run it from within the origin module, but not when the module is imported to another script. It only ever reads the variables defined in the origin module.</p>
  <p>I also tried:</p>
  <pre><code>import __main__
  for var_name in __main__.__dict__:
  </code></pre>
  <p>But that didn't work either. How can I get this function to work when imported into another script?</p>
  <p>Thanks!</p>