[Tutor] Listing function arguments
python at bernardlebel.com
Thu Sep 2 00:32:30 CEST 2004
I was simply looking at listing the function parameter names, nothing more.
I wanted to know what the funciton uses for paramter names, so I can assign
values to variables of the same name and pass them to the function.
In the example I gave I provide default values for these arguments, but
sometimes you want to know before hand what to supply to the function.
However, unless you're working in PythonWin, it's not obvious.
Anyway the tips given by Kent and Andrei are exactly what I wanted:
help( myfunction )
----- Original Message -----
From: "Alan Gauld" <alan.gauld at blueyonder.co.uk>
To: "Bernard Lebel" <python at bernardlebel.com>; <tutor at python.org>
Sent: Wednesday, September 01, 2004 9:56 PM
Subject: Re: [Tutor] Listing function arguments
> > Is there a way to list the arguments that a variable is accepting?
> > For instance, the first line of a function looks like this:
> > def cmcopy( aClients = , sSource = '', sTarget = '', iSource =
> 0 ):
> > So I'd like to know the argument names, for
> > 1- Know the order at wich the arguments must be passed
> > 2- Know what variables to supply for arguments
> Lets get our terminology straight first.
> aClients, aSource etc are the parameter names of the function cmcopy
> If I do:
> L = [1,2,3]
> s = 'fred'
> t = 'tom'
> src = 42
> The variable names are: L, s, t, src
> but the *arguments* are just the values that those variables hold
> and they are assined the temporary names
> aClients, sSource, sTarget, iSource
> for the duration of the function call.
> Thus if I do:
> There are no argument names, but the argument values are:
> [1,2,3,], 'fred','tom',42
> Almost exactly as they were above (except that the lists are not
> also referenced by the variables!)
> Which names do you want? And what dso you think you can do with them?
> If we know what you are trying to achieve we might be able to offer
> a better solution. :-)
> Alan G.
More information about the Tutor