Inconsistence syntax in os module?

Lars Kellogg-Stedman lars at larsshack.org
Tue Feb 5 06:50:42 CET 2002


Howdy all,

I'm growing increasingly frustrated with the os module, in particular 
with its implementation of the system() and popen() calls.  The 
traditional (e.g., libc) implementation of both of these calls spawns a 
/bin/sh process to run the command, with the associated problems of 
shell metacharacter interpretation, the cost of an extra fork(), and so 
forth.

On the other hand, the popen2 module (and thus, at least on unix, the 
os.popen2(), os.popen3(), etc. functions) will also accept a *list* as 
the command argument.  In this situation, the command is exec()'d 
directly, without the intervening shell (since we no longer need the 
shell to perform tokenization for us).

Rewriting system() and popen() to be consistent with popen2() and 
friends is trivial, especially if one writes the implementations in python.

Is there a reason why the stock implementation differs in this fashion?

Thanks,

-- Lars




More information about the Python-list mailing list