I have the following code in file abc.py:
import subprocess
def evaluate():
for i in range(5):
print("Printing", i)
subprocess.call(['ls', '-lrt'])
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
evaluate()
Now when I call using python abc.py > out.dat, the output file contains the result of 'ls -lrt' five times which is followed by printing statements in the code. Why is it happening so and what should I do if I need to get output as:
printing 0
(results of ls -lrt here)
~~~~~~~~~~~~~~~~~~~~~~~
printing 1
.
.
.
and so on..?
Thank you..