[Python-ideas] Suprocess functionality partitioning
Andrew Barnert
abarnert at yahoo.com
Thu Jun 13 03:56:25 CEST 2013
On Jun 12, 2013, at 12:32, anatoly techtonik <techtonik at gmail.com> wrote:
> Something needs to be done about subprocess API, which got overly complicated.
>
> The idea is to have:
> shutil.run() - run command through shell, unsafe
> sys.run() - run command directly in operating system, ?safe
What does "run" mean? Is it equivalent to call, check_call, check_output, or something else?
I find myself needing both check_call (to pass output straight through) and check_output (to process it) very often. I'd be happy with simplifying those. But not with simplifying one and losing the other.
Also, how often do you really need shell=True? I think providing a simpler way to do that will be more of an attractive nuisance than a help. (Many of the subprocess questions on Stack Overflow come down to people using shell=True, not knowing why they used it, and not knowing how to deal with it.)
> Both should be API compatible (unblocking stdin/stdout read etc.).
You're suggesting that these actually provide a Popen-like object that the caller then has to communicate() with or equivalent? Because that's already way more complicated than what I need for simple cases, and won't be that much simpler than just using Popen is today. Really, the only thing you can eliminate that way is the shell flag.
> Currently, subprocess calls are unreadable in any Python code - many
> conditions makes its behaviour hard to predict and memorize. By
> partitioning shell and out-of-shell execution, the documentation will be
> easier to grasp and reference to. Maybe it will be even possible to add
> some 2D table of various subprocess states that affect behavior.
> --
> anatoly t.
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
More information about the Python-ideas
mailing list