title: How can i run a python 2.x function from a 3.x built with arguments? PSS/E
body: <p>Hi I'm having a function that looks like it is only working in a 2.x (2.7) system. But the rest of my program is written in python 3.4</p>
  
  <p>The file <strong>a.py</strong> (version 2.7) was a script i could run in 2.7 by calling the script as:</p>
  
  <pre><code>import psspy    
  openPath='busSystem.raw'
  saveToPath='busSystem_out.raw'
  
  #Open a case file
  psspy.read(0,openPath)
  do some calculation...
  
  #Save to another case file
  psspy.rawd_2(0,1,[1,1,1,0,0,0,0],0,saveToPath)
  </code></pre>
  
  <p>And then calling the following code from python 3.4 in <strong>b.py</strong> workes</p>
  
  <pre><code>import os
  os.system('c:\python27\python a.py')
  </code></pre>
  
  <p>But then I wanted to change the script in <strong>a.py</strong> to be a function with kwargs such as:</p>
  
  <pre><code>def run(openPath='busSystem.raw',saveToPath='busSystem_out.raw')
      #Open a case file
      psspy.read(0,openPath)
      do some calculation...
  
      #Save to another case file
      psspy.rawd_2(0,1,[1,1,1,0,0,0,0],0,saveToPath)
      do something more...
  </code></pre>
  
  <p>So I want to do something like</p>
  
  <pre><code>import os
  in = 'busSystem.raw'
  out = 'busSystem_out.raw'
  os.system('c:\python27\python a.py run(in, out)')
  # Or
  os.system('c:\python27\python a.py run(openPath=in,saveToPath=out)')
  </code></pre>
  
  <p>So the question is: </p>
  
  <ul>
  <li>how can I send parameters to another script's function?</li>
  <li>can I use both args and kwargs?</li>
  </ul>
  
  <p>I know if I could have run the script with python 3.4 i could have just imported the function as </p>
  
  <pre><code>from a import run
  run(in,out)
  </code></pre>
  
  <p>My solution for this would be to read the whole python script as a string, use str.replace('busSystem.raw',in) and str.replace(''busSystem_out.raw',out) and save it back as a <strong>a_new.py</strong>
  and run it as mentioned before.</p>
  
  <p>The script in <strong>a.py</strong> need to be in python version 2.7, because it is interacting with Siemens PSS/E 33, which only communicates through py2.7. </p>