os.popen vs os.system

F. Petitjean littlejohn.75 at news.free.fr
Tue May 17 14:27:19 EDT 2005


Le Tue, 17 May 2005 13:50:08 -0400, rbt a écrit :
> Is it more appropriate to use os.popen or os.system on a windows XP 
> client?

Nope. use the subprocess module  :-)

Microsoft had the great idea to embed white space inside a lot of
directories (compare C:\Program Files\ to /usr/bin ) which means that
you must find the right way to quote the command line string of
os.system() and this quoting is very tricky and under-documented. A
nightmare to thousands of developers which has a cost of millions of
dollars :-(

Exercice for the reader : write a windows application which can only be
invoked from the command line (or from another program) not by clicking
on a cute icon. Extra bonus points if the path to this executable
contain (after Program Files) a company name with some characters hard
to type on some keyboards (or with some locales), if the executable name
has also difficult to type characters and if the case is checked
(windows file system is case preserving).



More information about the Python-list mailing list