Open a file in Sublime Text and wait until it is closed while Python script is running
<p>I want to open a file in Sublime Text while my Python script waits until I have <em>closed</em> the editor. I have tried <code>subprocess.check_call</code> and <code>subprocess.Popen</code>.  However, the call ends after the file is opened, rather than waiting for the file to close.  How can I wait until the file is closed in Sublime Text?</p>

<pre><code>p = subprocess.Popen(['subl', 'parameters.py'])
p.communicate()
</code></pre>



<pre><code>p = subprocess.check_call(['subl', 'parameters.py'])
</code></pre>

<p>When you just call <code>subl parameters.py</code> it does not block the thread, but you can use the <code>-w</code> flag to do so. I.e. just call</p>

<pre class="lang-py prettyprint-override"><code>subprocess.Popen(["subl", "-w", "parameters.py"]).wait()
</code></pre>

<p>and it should work as requested.</p>

python subprocess sublimetext popen