Please consider the following options:
1) run the two scripts from your shell using a pipe like this:
first.py | second.py
2) re-write the scripts so you can import the first script in the second, for example like this:
the first script:
# first.py
# the method returning the numbers as a list (formerly putting them to stdout)
def get_numbers():
# do something to collect the list of the numbers
return numbers_list
the second script:
# second.py
from .first import get_numbers
# the method using the numbers (formerly getting them from stdin)
def process_numbers():
numbers = get_numbers()
# do something to process the numbers
If you really want to call the other script as is, you can do it this way:
#second.py
from subprocess import Popen, PIPE
def process_numbers():
p = Popen(["first.py", "argument"], stdout=PIPE, stderr=PIPE)
out, err = p.communicate()
# the out variable now contains the standard output of the first script
# do something to process the numbers