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
The file a.py (version 2.7) was a script i could run in 2.7 by calling the script as:
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)
And then calling the following code from python 3.4 in b.py workes
import os
os.system('c:\python27\python a.py')
But then I wanted to change the script in a.py to be a function with kwargs such as:
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...
So I want to do something like
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)')
So the question is:
- how can I send parameters to another script's function?
- can I use both args and kwargs?
I know if I could have run the script with python 3.4 i could have just imported the function as
from a import run
run(in,out)
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 a_new.py and run it as mentioned before.
The script in a.py need to be in python version 2.7, because it is interacting with Siemens PSS/E 33, which only communicates through py2.7.