title: Viewing Variables of Another Python File Without Importing/Running
body: <p>I have been trying to read python files and print its variables for a while now. Is it possible to <em>view and print</em> the variables of another file without importing or running it? Everything I have already searched only explains how to import or use execfile, etc... (disclaimer, I am probably dumb)</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code>for vars in dir():
     print(vars)
  </code></pre>
  
  <p>Now, this works perfectly fine for the file it is being run from, but when I try this code:</p>
  
  <pre><code>for vars in file:
     print(vars)
  </code></pre>
  
  <p>(file is simply path.read())</p>
  
  <p>Well, it gives me every character of the file on a new line. I have no idea if my loop is correct at all. Will I have to write something that will manually find each variable, then add it into a list?</p>