should these be fixed for python 2.4?

Grant Edwards grante at visi.com
Fri Oct 1 16:21:10 EDT 2004


On 2004-10-01, Alexander Schmolck <a.schmolck at gmx.net> wrote:

> 1. ``os.system`` (and co): Shouldn't ``os.system``'s signature really be
>    ``os.system(cmd, arg1, arg2,...)`` rather than ``os.system(some_string)``?

No. It's just a wrapper around system(), so why muck with the
signature?

------------------------------------------------------------------------
SYSTEM(3)                  Linux Programmer's Manual   SYSTEM(3)

NAME
       system - execute a shell command

SYNOPSIS
       #include <stdlib.h>

       int system(const char *string);
       
------------------------------------------------------------------------

>    Otherwise ``some_string`` almost certainly will be
>    constructed by something along the lines of
>    ``os.system('convert %s %s' % (infile, outfile))`` which of
>    course is broken (e.g. ``infile = "with space"``). 

Maybe, maybe not.  Why add the command construction overhead to
os.system()?

>    I don't think it's even possible to do the right thing
>    platform-independently.

Sorry, I've no idea what you're talking about.  os.system() is
supposed to hand a string to the shell.  What that string means
is a matter for you and the shell to discuss.  How that string
is constructed is up to you.  os.system() has nothing to do
with it.

>    So why not just allow ``os.system('convert',infile, outfile)`` as a
>    backward compatible extension that "does the right thing"?

Because it's not possible to define what "the right thing" is.
You'd have to know both the semantics and syntax of the shell
and the intent of the programmer to figure out "the right
thing".  That's a pretty tall order for something that's
supposed to be a very thin wrapper around Posix system().

-- 
Grant Edwards                   grante             Yow!  I'd like TRAINED
                                  at               SEALS and a CONVERTIBLE on
                               visi.com            my doorstep by NOON!!



More information about the Python-list mailing list