[Tutor] Listing function arguments

Bernard Lebel python at bernardlebel.com
Thu Sep 2 20:36:31 CEST 2004

Hi Alan,

The ultimate end to my question was to know the actual order of arguments. I
know I can send a,b,c, as values for parameters x,y,z.
However, I want to know in what order I have to supply values for the
function to work.
If I supply the wrong value to a given parameter, I won't go very far :-)

In this case, I need to know if sSource is before or after sTarget, and on
the same roll why not check if there are arguments I may have forgotten.
Plus, the help() function is great, but I know document each parameter in
the doc string, so I can see if I make a mistake.

Thanks for the help!

----- Original Message ----- 
From: "Alan Gauld" <alan.gauld at blueyonder.co.uk>
To: "Bernard Lebel" <python at bernardlebel.com>; <tutor at python.org>
Sent: Thursday, September 02, 2004 7:59 AM
Subject: Re: [Tutor] Listing function arguments

> > 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.
> I'm still slightly confused about why you want to give the
> variables the parameter *names*. You shouldn't need to give the
> variables the same name as the parameters.
> For example:
> def f(x=0,y=1,z=2): return x+y+z
> a = 3
> b = 7
> c = 42
> print f(a,b,c)   # -> 52
> What is important is the type and sequence of the parameters.
> The variables passed as arguments can have completely different
> "names". There is a slight tweak with named parameters
> where you have a many parameters and want to pass a subset
> not necessarily in the order specified, and I guess that's what
> you are trying to do?
> > Anyway the tips given by Kent and Andrei are exactly what I wanted:
> > help( myfunction )
> And yes that would tell you the parameter names so that you can
> assign the arguments by name, but you still don't need to name
> your variables with the same names. Returning to our example:
> print f(z=b)
> we assign our variable b to the parameter named z.
> HTH,
> Alan G.

More information about the Tutor mailing list