<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 29 January 2015 at 03:47, Nick Coghlan <span dir="ltr"><<a href="mailto:ncoghlan@gmail.com" target="_blank">ncoghlan@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div id=":20h" class="a3s" style="overflow:hidden">I still suspect we should be offering a simpler way to decouple the<br>
creation of the pipes from the subprocess call, but I have no idea<br>
what that API should look like,</div></blockquote><div><br></div><div>Presumably that would need some kind of object representing a not-yet-started process. Technically, that could be Popen, but for backwards compatibility the Popen constructor needs to start the process, and p = Popen(..., start=False) seems inelegant. <br><br></div><div>Let's imagine it's a new class called Command. Then you could start coming up with interfaces like:<br><br></div><div>c = subprocess.Command(...)<br></div><div>c.stdout = fileobj<br></div><div>c.stderr = fileobj2<br></div><div># Or<br>c.capture('combined')  # sets stdout=PIPE and stderr=STDOUT<br></div><div># Maybe get into operator overloading?<br></div><div>pipeline = c | c2<br></div><div># Could this work? Would probably require threading<br></div><div>c.stdout = BytesIO()<br></div><div>c.stderr_decoded = StringIO()<br></div></div># When you've finished setting things up<br></div><div class="gmail_extra">c.run()  # returns a Popen instance<br><br><br>N.B. This is 'thinking aloud', not any kind of proposal - I'm not convinced by any of that API myself.<br><br></div><div class="gmail_extra">Thomas<br></div></div>