Subprocess.communicate prints newline to standard output
<p>I have a script that calls ffprobe, parses its output and outputs it to the console.</p>

<p>Here's a stripped-down version of it without the parsing code and command-line options:</p>

<pre><code>"""Invoke ffprobe to query a video file and parse the output"""

def ffprobe(fname):
    import subprocess as sub
    import re
    p = sub.Popen(['ffprobe', fname], stderr=sub.PIPE)
    stdout, stderr = p.communicate()

def main():
    ffprobe("foo.mp4")
    #print options.formatstr % locals()

if __name__ == '__main__':
    main()
</code></pre>

<p>You can see that the only <code>print</code> statement in my code is commented out, so the program shouldn't really output anything.  However, this is what I get:</p>

<pre><code>mpenkov@misha-desktop:~/co/youtube$ python ffprobe.py foo.mp4

mpenkov@misha-desktop:~/co/youtube$ python ffprobe.py foo.mp4

mpenkov@misha-desktop:~/co/youtube$ python ffprobe.py foo.mp4
</code></pre>

<p>A newline is mysteriously output by each invocation.  Where is it coming from, and how can I deal with it?</p>

<p>There appears to be a similar SO question, except it's not using the <code>communicate</code> call (http://stackoverflow.com/questions/7985334/python-subprocess-proc-stderr-read-introduce-extra-lines).</p>
