[Python-ideas] Adding a subprocess.CompletedProcess class (original) (raw)
Nick Coghlan ncoghlan at gmail.com
Sun Feb 1 02:01:16 CET 2015
- Next message: [Python-ideas] Adding a subprocess.CompletedProcess class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On 30 Jan 2015 07:11, "Thomas Kluyver" <thomas at kluyver.me.uk> wrote:
On 29 January 2015 at 03:47, Nick Coghlan <ncoghlan at gmail.com> wrote:
I still suspect we should be offering a simpler way to decouple the creation of the pipes from the subprocess call, but I have no idea what that API should look like, 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. Let's imagine it's a new class called Command. Then you could start coming up with interfaces like: c = subprocess.Command(...) c.stdout = fileobj c.stderr = fileobj2 # Or c.capture('combined') # sets stdout=PIPE and stderr=STDOUT # Maybe get into operator overloading? pipeline = c | c2 # Could this work? Would probably require threading c.stdout = BytesIO() c.stderrdecoded = StringIO() # When you've finished setting things up c.run() # returns a Popen instance N.B. This is 'thinking aloud', not any kind of proposal - I'm not convinced by any of that API myself.
I'm personally waiting for someone to get annoyed enough to try porting Julia's Cmd objects to Python and publish the results on PyPI :)
Cheers, Nick.
Thomas
Python-ideas mailing list Python-ideas at python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150201/06ea6aef/attachment.html>
- Next message: [Python-ideas] Adding a subprocess.CompletedProcess class
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]