<div class="gmail_quote">On Tue, Aug 24, 2010 at 4:38 AM, Leon Derczynski <span dir="ltr"><<a href="mailto:leon@dcs.shef.ac.uk">leon@dcs.shef.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi,<br>
<br>
I would like to run an external program, and discard anything written<br>
to stderr during its execution, capturing only stdout. My code<br>
currently looks like:<br>
<br>
def blaheta_tag(filename):<br>
        blaheta_dir = '/home/leon/signal_annotation/parsers/blaheta/'<br>
        process = subprocess.Popen([blaheta_dir + 'exec/funcTag',<br>
blaheta_dir + 'data/', filename], cwd=blaheta_dir,<br>
stdout=subprocess.PIPE)<br>
        process.wait()<br>
        return process.communicate()[0]<br>
<br>
This returns stdout, and stderr ends up printing to the console. How<br>
can I disregard anything sent to stderr such that it doesn't appear on<br>
the console?<br></blockquote><div><br>Just add `stderr=subprocess.PIPE` keyword in the Popen call. <br></div></div><br>-- <br>With best regards,<br>Daniel Kluev<br><br>