Calling a python script which has input Fields
Question: I am writing a Python script that has to call a second python script which has
input fields. The normal way to call the second script in Linux command window
is:

    
    
    python 2ndpythonscript.py input_variable output_variable
    

Now, I want to call this script from inside the first script. How do I do it?
Thanks in advance.


Answer: Use the [`subprocess`](https://docs.python.org/2/library/subprocess.html)
module, e.g.:

    
    
    import subprocess
    retcode = subprocess.call(['python', '2ndpythonscript.py', 'input_variable', 'output_variable'])
    

There are different specialized functions in the module which you can use if
you want only the return code, only the output, both, stdout/stderr redirected
in custom pipes and so on.

