A question??

Alan Gauld alan.gauld at btinternet.com
Sun Aug 29 12:53:43 EDT 2004


On 25 Aug 2004 22:38:06 -0700, rattan at cps.cmich.edu (Ishwar
Rattan) wrote:

> def run(program, *args):
>     pid = os.fork()
>     if not pid:
>          os.execvp(program, (program,)+args)

> What is the interpretation of *args (in def run(..)?
> Looks like a reference to me, so, how does one decide when to use
> a reference or not?

Its not a reference its a placeholder for an unspecified number
of arguments. (Actually I think it's technically a tuple of
arguments?) You can think of it like the C va_arg construct 
used for functions like printf().

There is also a **args construct which is for a dictionary of
keyword arguments. I'm no expert on these but thats what they are
about.

Here is the url to the documentation:

http://docs.python.org/ref/function.html

HTH,

Alan G.

Author of the Learn to Program website
http://www.freenetpages.co.uk/hp/alan.gauld



More information about the Python-list mailing list