title: How to import global variables in python from a class module in another file?
body: <p>I have a file that contains the class definitions and functions I need to use in my main file to make the text cleaner. However, I'm having a problem with imported global variables. </p>
  
  <p>There is plenty of information at SO and other resources regarding how to make function variables global within the same code or how to use the global variables from an imported file. However, there is no information on how to access a variable from an imported file if the variable belongs to a function belonging to a class.</p>
  
  <p>I would appreciate any help on how to do it or why it cannot be done. Please skip the lecture on the dangers of using global variables like this as my situation requires such use.</p>
  
  <p>Edit: Sorry for not having an example in the original post. It's my first one. Below is an example of what I'm trying to accomplish.</p>
  
  <p>Let's say I have a file classes.py that contains:</p>
  
  <pre><code>class HelixTools():
      def calc_angle(v1, v2):
      v1_mag = np.linalg.norm(v1)
      v2_mag = np.linalg.norm(v2)
  
      global v1_v2_dot
      v1_v2_dot = np.dot(v1,v2)
      return v1_v2_dot
  </code></pre>
  
  <p>Then in my main text file I do:</p>
  
  <pre><code>from classes import HelixTools
  
  ht = HelixTools()
  v1 = some vector
  v2 = some other vector
  ht.calc_angle(v1,v2)
  print(v1_v2_dot)
  </code></pre>
  
  <p>The result is "v1_v2_dot" not defined. I need v1_v2_dot to use it as the input of another function.</p>