"Wayne Watson" <sierra_mtnv...@sbcglobal.net> wrote

What is meant by "The arguments are the same as for the Popen constructor.",
in Convenience Functions? In fact, what is such a function?

It means that there is a function which takes the same arguments
as the __init__() method of the Popen class.

They are convenience functions in that you don't need to create the class to use them you can just call them directly. THe payoff is that you lose some of the flexibility of using the class, but often you don;t need that.

class subprocess.Popen(args, bufsize=0, executable=None, stdin=None, stdout=None, stderr=None, preexec_fn=None, close_fds=False ....
Why not just class Popen instead of subprocess.Popen?

The notation is saying that there is a class defined in the
subprocess module called Popen with a constructor that
has the listed parameters. It is just a shorthand way of
expressing that.

In practice you would create an instance with either:

import subprocess
p = subprocess.Popen(....)

OR

from subprocess import Popen
p = Popen(....)

Is there a suggestion here that I need only do:
from subprocess import Popen
myProg=Popen()
myProg.call("wolf", "-h")

Even simpler, you only need:

from subprocess import call
myProg = call(["wolf", "-h"])

You need to put the command as the first entry of a list and each
argument as a separate entry

HTH,


--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to