Is there a clever way to pass arguments
d at davea.name
Thu Aug 9 03:07:04 CEST 2012
On 08/08/2012 08:41 PM, bruceg113355 at gmail.com wrote:
> Is there a way in Python to pass arguments without listing each argument?
> For example, my program does the following:
> testData (z, z, z, z, z, z, z, z)
> Is there a clever way to pass arguments in a single statement knowing that each argument is a sequential index from a list?
> I cannot change the function definition.
If a function is expecting exactly 8 arguments, and z is a list of
length 8, you can call the function like:
if z is longer, then you'd need something like (untested)
The * basically turns a list into separate arguments, and these are then
applied to the formal parameters.
More information about the Python-list