Best way to convert a list into function call arguments?

bwooster47 at gmail.com bwooster47 at gmail.com
Thu May 5 09:20:20 EDT 2005


I'm a newcomer to python - what is the best way to convert a list into
a function call agruments?

For example:

list = (2005, 5, 5)

date = datetime.date( list )
fails with:
TypeError: function takes exactly 3 arguments (1 given)

I assumed that since Python allows multiple assignments per statement,
such as
a, b, c = list
the date call above should work...

So, what is the best way to call date?
This works, but looks clunky:
date = datetime.date( list[0], list[1], list[2 )

Thanks!




More information about the Python-list mailing list