Why is not the code executed serially in a python for loop
<p>I have the following functionality in a python script:</p>

<pre><code>invoke the shell to create some files(it is a split command from the shell)
for f in a folder
    open f and write something

commands..
</code></pre>

<p>I have seen that when the program goes to commands after the execution of the for loop many files have not been altered correctly. Some yes and some others no, randomly.</p>

<p>Actually before the loop the files are created with a shell command invoked with popen.subprocess. What is happening is that somewhat the for loop is executed when the popen.subprocess  has not been terminated.How can i force the program to start the for loop as soon as the shell command terminates?</p>
