title: Is there a way to import a variable in python without looping code?
body: <p>I have looked at multiple different questions and answers but nothing I have looked at is helping me in the slightest. I am using Python 3 for all of this.</p>
  
  <p>I am having a bit of trouble using python to transfer a variable to be used in a command-line prompt through python code. I am using os.system, and would prefer to use this, to execute a second python file, in the same folder.
  The opening through command prompt works after a bit of testing, but when I try to import a variable from the first python code, it loops through the entire first bit of code.</p>
  
  <p>My first python code is as follows:</p>
  
  <pre><code>import os
  variable_to_transfer=input()
  os.system('cmd /c "python file2.py"')
  </code></pre>
  
  <p>My second python code is as follows:</p>
  
  <pre><code>import os
  from file1.py import variable_to_transfer
  command='cmd /k "ping {0}"'.format(variable_to_transfer)
  os.system(command)
  </code></pre>
  
  <p>When I run this set of code it runs through the first code once, goes to the second code and doesn't do anything at the line</p>
  
  <pre><code>from file1.py import variable_to_transfer
  </code></pre>
  
  <p>I intend for my codes to transfer the variable but it just loops. Any way to fix this?</p>