To compile a python script without executing it, do
python -m py_compile my_script.py
[Courtesy: stackoverflow]
python -m py_compile my_script.py
[Courtesy: stackoverflow]
for param in `cat params.txt`; do
# wait if more than 7 jobs are running together
njobs=`ps aux | grep myscript | wc -l`
if [ $njobs -gt 8 ]; then # 7 jobs + 1 grep
while [ $njobs -gt 8 ]; do
sleep 10
done
fi
python myscript.py param & # schedule background job here
done
f = open(fname, 'r')
data = f.read()
f.close()
to read a file, and
f = open(fname, 'w')
f.write(text)
f.close()
to write a file. import gzip
f = gzip.open(fname, 'rb')
data = f.read()
f.close()
to read a gzip-compressed file, and
f = gzip.open(fname, 'wb')
f.write(data)
f.close()
to write a gzip-compressed file.