0

I am reading "Programming Python" 4e and on Page182 there is this line of code:

os.execlp('python', 'python', 'child.py', str(parm))

The purpose of the code is to run the script 'child.py'. However, I do not understand why there are two 'python's in the argument list. I believe that execlp take arguments like execlp(program, cmdarg1, cmadarg2,... cmdargN). So here the first 'python' is the program, that's ok; but what is the second 'python' for? If that's an argument, then we are basically running "python python child.py" and that does not make sense.

Actually I tried to use:

os.execlp('python', 'child.py', str(parm))

instead, but the result was that a new instance of python environment is launched without running the 'child.py' script.

So, how should I interpret the two 'python's in the argument list?

3
  • Try here: stackoverflow.com/questions/13439938/execlp-in-python or this one: stackoverflow.com/questions/14174366/… Commented Oct 16, 2013 at 2:51
  • 2
    FYI exec() is something else entirely, as I'm sure at least one poster came in prepared to tell you (and how you should never use it) Commented Oct 16, 2013 at 2:54
  • @Yohann thank you for the link, that solved my question. Have no idea how I missed that when searching:( Commented Oct 16, 2013 at 14:10

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.