os.system question

Kevin Walzer kw at codebykevin.com
Thu Aug 14 01:54:14 CEST 2008


Fredrik Lundh wrote:

> 
> not talking for the 3.X developers here, but os.popen is a binding to 
> the POSIX popen function, so I'm not sure it makes that much sense to 
> actually deprecate it.
> 
> the os.popen[234], popen2, and commands stuff are different -- they're a 
> a series of attempts to provide more functionality by building on 
> lower-level primitives, something that the subprocess module does a lot 
> better.
> 
> </F>
> 

I think the 'commands' module is nice--it's very handy in parsing output 
from a 'fire-and-forget' system call. I'd hate to see it removed entirely.

I'm also skeptical of the value of subprocess, at least as a complete 
replacement for os.popen (the original version): it currently provides 
no way to set a 'non-blocking' mode. I make heavy use of this kind of 
call in my code:

self.file = os.popen('do stuff here'), 'r', os.O_NONBLOCK)

Having this kind of capability built into the language strikes me as 
important. If subprocess lacks it, and one has to go to the ActiveState 
cookbook to implement similar functionality, then it's hard for me to 
embrace it as a replacement.

N.B: I develop on a Unix-like system (Darwin/MacOS), so others 
understand where I'm coming from.

-- 
Kevin Walzer
Code by Kevin
http://www.codebykevin.com



More information about the Python-list mailing list