title: List user defined variables, python
body: <p>I am trying to iterate through the variables set in a python script. I came across the following:</p>
  
  <p><a href="https://stackoverflow.com/questions/430811/enumerate-or-list-all-variables-in-a-program-of-your-favorite-language-here">Enumerate or list all variables in a program of [your favorite language here]</a></p>
  
  <p>and in the first example:</p>
  
  <pre><code>#!/us/bin/python                                                                                    
  
  foo1 = "Hello world"
  foo2 = "bar"
  foo3 = {"1":"a", "2":"b"}
  foo4 = "1+1"
  
  for name in dir():
      myvalue = eval(name)
      print name, "is", type(name), "and is equal to ", myvalue
  </code></pre>
  
  <p>It lists all the variables stored in memory. I want to isolate the variables I have created in my script and not list the system variables created by default. Is there any way to do this?</p>