Is it possible to determine what a function needs for parameters -

Steven D'Aprano steve at REMOVE.THIS.cybersource.com.au
Wed May 2 13:08:49 EDT 2007


On Wed, 02 May 2007 07:22:07 -0700, rh0dium wrote:

> Hi all,
> 
> Below is a basic threading program. The basic I idea is that I have a
> function which needs to be run using a queue of data.  Early on I
> specified my function needed to only accept basic parameters ( no
> postional *args or *kwargs ) but now I am re-writing it and I want to
> accept these.  Is there anyway to determine what parameters are needed
> by a given function and format the arguments given appropriately.

Is this meant to be just a programming exercise to see how clever you can
be? It's okay if it is, but if it is meant to be something useful,
well, I can't imagine ever being in a situation where I know I have
to pass arguments (say) 4, 5, "Hello", and None to a function, but not
know whether they should be positional arguments or keyword arguments.

Or, to put it another way... the usual procedure is for the developer
(that's you) to read the function API to find out what arguments the
function expects, and how it expects them, and then the developer
modifies the parameters used accordingly.



-- 
Steven.




More information about the Python-list mailing list