If I have a script 'sp_test.py' as follows:
import sys
def sp_test(a=0,b=0,c=0):
print(a)
print(b)
print(c)
return str(a)+str(b)+str(c)
if __name__ == "__main__":
sp_test(sys.argv[1],sys.argv[2],sys.argv[3])
If I want to call it from another python script I can use :
import sys
import subprocess
subprocess.call([sys.executable, 'sp_test.py', '1','2','3'])
However I would expect the output to be:
1
2
3
123
The output is actually:
1
2
3
0
Why is this?
I noticed this when I was trying methods to call this script from another python script - the return value seems incorrect - is this the expected behavior? If so why?