title: List all variables used in a python script
body: <p>I have a long python script which I would like to partly export to smaller scripts. Is there a way to gather all variables which are used in the specific part of the script? I don't want to define all the variables that are not used for the script.
  Example:</p>
  
  <pre><code>var1 = "folder"
  var2 = "something else"
  var3 = "another thing"
  
  #part of the script I would like to use seperatly
  dosomething(var1,var2)
  #end of the part
  
  dosomethingelse(var3)
  </code></pre>
  
  <p>Is there a way to list var1 and var2 as a part of my script, but not var3 as I won't need it for my new subset script?</p>