This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: function for convinience and robustness
Type: enhancement Stage:
Components: Library (Lib) Versions:
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: aschmolck, astrand, jlgijsbers
Priority: normal Keywords:

Created on 2004-10-04 23:00 by aschmolck, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg54275 - (view) Author: Alexander Schmolck (aschmolck) Date: 2004-10-04 23:00
I propose to add the the following convenience function:'some_program', infilename, '-o', outfilename) 

as equivalent to 

os.spawnvp(os.P_WAIT, 'some_program', ['some_program',
infilename, '-o', outfilename])


Newbies and more experienced programmers alike are
likely to make incorrect use of os.system for the
common task of running a process passing a couple of
arguments, when they should really be using os.spawnvp,
but the latter has an awkward interface and is much
more difficult to find in the docs (in a recent thread
[1]; a couple of regulars admitted either having been
bitten or at least finding os.spawnvp difficult to use
or awkward to remember).

As a consequence this (broken): 

os.system('some_program %s -o %s' % (infilename,

is often used instead of

os.spawnvp(os.P_WAIT, 'some_program', ['some_program',
infilename, '-o', outfilename])

which works correctly, but is more awkward (and also
easy to get wrong, e.g. note the double occurence of

I propose to add the covenience function for the common
case (or at least some doc improvements) to make such
brittle code less common and especially to aid less
experienced programmers who are unlikely to even hit
upon os.spawnvp in the docs.

A similar function would also be useful for popen*
style use (which currently cannot be done at all
without shell-escaping by hand).

Further rationale and an implementation can be found in

[1] Message-ID: <> or
msg54276 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2004-11-16 20:07
Logged In: YES 

I think this is solved by 
msg54277 - (view) Author: Johannes Gijsbers (jlgijsbers) * (Python triager) Date: 2004-11-16 20:25
Logged In: YES 

So it has. Closing.
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 40983
2004-10-04 23:00:25aschmolckcreate