The second attempt - this time shell accepts the main integration challenge.
This foo.py contains the following:
def foo():
foo = ('String', 'Tuple', 'From', 'Python' )
return foo
Then write a bash script as follows:
#!/bin/bash
FOO=`python -c 'from foo import *; print " ".join(foo())'`
for x in $FOO:
do
echo "This is foo.sh: $x"
done
The rest is the first answer that drives integration from the end of Python.
Python
import os
import subprocess
foo = ('String', 'Tuple', 'From', 'Python' )
os.putenv('FOO', ' '.join(foo))
subprocess.call('./foo.sh')
bash
#!/bin/bash
for x in $FOO
do
echo "This is foo.sh: $x"
done
source
share