<p>I would like to replicate this in python:</p>

<pre><code>gvimdiff &lt;(hg cat file.txt) file.txt
</code></pre>

<p>(hg cat file.txt outputs the most recently committed version of file.txt)</p>

<p>I know how to pipe the file to gvimdiff, but it won't accept another file:</p>

<pre><code>$ hg cat file.txt | gvimdiff file.txt -
Too many edit arguments: "-"
</code></pre>

<p>Getting to the python part...</p>

<pre><code># hgdiff.py
import subprocess
import sys
file = sys.argv[1]
subprocess.call(["gvimdiff", "&lt;(hg cat %s)" % file, file])
</code></pre>

<p>When subprocess is called it merely passes <code>&lt;(hg cat file)</code> onto <code>gvimdiff</code> as a filename.</p>

<p>So, is there any way to redirect a command as bash does?
For simplicity's sake just cat a file and redirect it to diff:</p>

<pre><code>diff &lt;(cat file.txt) file.txt
</code></pre>

There is also the commands module:
```
```
import commands

status, output = commands.getstatusoutput("gvimdiff <(hg cat file.txt) file.txt")
```
```
There is also the popen set of functions, if you want to actually grok the data from a command as it is running.