Re: [Python-3000] os.popen versus subprocess.Popen

2008-04-22 Thread Guido van Rossum
I need to retract this. os.popen() has a 'mode' flag that indicates reading or writing but also specifies text vs. binary. So os.popen(..., 'r') should return a text stream, while os.popen(..., 'rb') should return a binary stream. The subprocess module has similar options, though the default is ge

Re: [Python-3000] os.popen versus subprocess.Popen

2008-04-22 Thread Facundo Batista
2008/4/22, Guido van Rossum <[EMAIL PROTECTED]>: > I still think os.popen() should be reimplemented on top of subprocess, > and add the same optional flags as the open() function has grown to > indicate encoding and buffering. os.popen() is deprecated in 2.6, with the recommendation of using t

Re: [Python-3000] os.popen versus subprocess.Popen

2008-04-22 Thread Andrew McNabb
On Tue, Apr 22, 2008 at 12:57:56PM -0300, Facundo Batista wrote: > > - Why can't I write "ls -l", instead of ["ls", "-l"] (people ends > writing "ls -l".split()) That's the best thing about subprocess. Whenever I've used APIs that accept a single string instead of list of arguments, I've quickly

Re: [Python-3000] os.popen versus subprocess.Popen

2008-04-22 Thread Facundo Batista
2008/4/22, Andrew McNabb <[EMAIL PROTECTED]>: > That's the best thing about subprocess. Whenever I've used APIs that > accept a single string instead of list of arguments, I've quickly > descended into quoting hell. I don't understand why, could you please provide me one example or two? Thank

Re: [Python-3000] os.popen versus subprocess.Popen

2008-04-22 Thread Andrew McNabb
On Tue, Apr 22, 2008 at 03:33:30PM -0300, Facundo Batista wrote: > 2008/4/22, Andrew McNabb <[EMAIL PROTECTED]>: > > > That's the best thing about subprocess. Whenever I've used APIs that > > accept a single string instead of list of arguments, I've quickly > > descended into quoting hell. > >

Re: [Python-3000] os.popen versus subprocess.Popen

2008-04-22 Thread Martin (gzlist)
On 22/04/2008, Facundo Batista <[EMAIL PROTECTED]> wrote: > 2008/4/22, Andrew McNabb <[EMAIL PROTECTED]>: > > > > That's the best thing about subprocess. Whenever I've used APIs that > > accept a single string instead of list of arguments, I've quickly > > descended into quoting hell. > > > I

Re: [Python-3000] os.popen versus subprocess.Popen

2008-04-22 Thread Oleg Broytmann
On Tue, Apr 22, 2008 at 01:39:11PM -0600, Andrew McNabb wrote: > "cat %s" % filename > > then your program would break if filename contained spaces. It'd break even worse if the filename contains ';' or any other command-separated character (&&, ||, etc.) Oleg. -- Oleg Broytmann

Re: [Python-3000] os.popen versus subprocess.Popen

2008-04-22 Thread Guido van Rossum
On Tue, Apr 22, 2008 at 8:57 AM, Facundo Batista <[EMAIL PROTECTED]> wrote: > 2008/4/22, Guido van Rossum <[EMAIL PROTECTED]>: > > I still think os.popen() should be reimplemented on top of subprocess, > > and add the same optional flags as the open() function has grown to > > indicate encodi

Re: [Python-3000] os.popen versus subprocess.Popen

2008-04-22 Thread Facundo Batista
2008/4/22, Andrew McNabb <[EMAIL PROTECTED]>: > Here's a really simple example: > > ("bash", "-c", 'FILE="/tmp/a b c"; cat "$FILE"') > > That's pretty simple as a list of arguments. But if you do it as a > single string, you get: > > 'bash -c \'FILE="/tmp/a b c"; cat "$FILE"\'' > > It can ge

Re: [Python-3000] os.popen versus subprocess.Popen

2008-04-22 Thread Andrew McNabb
On Tue, Apr 22, 2008 at 04:52:42PM -0300, Facundo Batista wrote: > > I think that force me to write a tuple or a list just in case I'd need > to write a string that uses simple and double quotes, or backslashes, > because it's "ugly", don't worth it. Or spaces, or user input, or any special shell

Re: [Python-3000] os.popen versus subprocess.Popen

2008-04-22 Thread Mike Meyer
On Tue, 22 Apr 2008 16:52:42 -0300 "Facundo Batista" <[EMAIL PROTECTED]> wrote: > 2008/4/22, Andrew McNabb <[EMAIL PROTECTED]>: > > > Here's a really simple example: > > > > ("bash", "-c", 'FILE="/tmp/a b c"; cat "$FILE"') > > > > That's pretty simple as a list of arguments. But if you do it a