Snippet: The leanest Popen wrapper
Chris Rebert
clp2 at rebertia.com
Wed Aug 3 13:27:41 EDT 2011
On Wed, Aug 3, 2011 at 8:29 AM, Phlip <phlip2005 at gmail.com> wrote:
> Groupies:
>
> This is either a code snippet, if you like it, or a request for a
> critique, if you don't.
>
> I want to call a command and then treat the communication with that
> command as an object. And I want to do it as application-specifically
> as possible. Anyone could think of a way to productize this:
>
> def command(*cmdz):
>
> process = Popen( flatten(cmdz),
flatten() being defined as...?
> shell= True,
I would strongly encourage you to avoid shell=True. You really don't
want to have to worry about doing proper shell escaping yourself.
> stdout= subprocess.PIPE,
> stderr= subprocess.PIPE,
> bufsize= 4096 )
Cheers,
Chris
More information about the Python-list
mailing list