Is there a clever way to pass arguments

Andrew Cooper amc96 at cam.ac.uk
Wed Aug 8 20:47:35 EDT 2012


On 09/08/2012 01:41, 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[0], z[1], z[2], z[3], z[4], z[5], z[6], z[7])
> 
> 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.
> 
> Thanks,
> Bruce
> 

testData(*z)

assuming that there are exactly 8 entries in z

see
http://docs.python.org/dev/tutorial/controlflow.html#more-on-defining-functions

~Andrew



More information about the Python-list mailing list