title: Python cross module variables and imports
body: <p>I see that there are other questions related to cross module variables, but they don't really fully answer my question.</p>
  
  <p>I have an application that I have split into 3 modules + 1 main application, mainly for ease of readability and maintainability.</p>
  
  <p>2 of these modules have threads with variables that need to be modified from other modules and other module threads.</p>
  
  <p>Whilst I can modify a module's variable from the main code, I don't appear to be able to modify one module's variable from another module unless I import every module into every other module.</p>
  
  <p>The example below where a&amp;b are imported into main and a module a needs to access a variable in module b:</p>
  
  <pre><code>main
   module a
     var a
   module b
     var a
  
  main
   a.a = 1
   b.a = 2
  
  module a
   b.a = 3
  
  module b
   a.a = 0
  </code></pre>
  
  <p>without importing module a into module b and importing module b into module a, can this be achieved globally through the main program ?</p>
  
  <p>If I do have to import a and b into main, and then import a into b and b into a, what are the implications in terms of memory and resource usage / speed etc ?</p>
  
  <p>I tried the suggestion from @abarnert:</p>
  
  <pre><code>#moda
  vara = 10
  
  #modb
  print(str(vara))
  
  #main
  import moda
  from moda import vara
  import modb
  </code></pre>
  
  <p>however I get "name error vara is not defined"</p>