Best way to convert a list into function call arguments?

bruno modulix onurb at xiludom.gro
Fri May 6 12:16:53 EDT 2005


bwooster47 at gmail.com wrote:
> I'm a newcomer to python - what is the best way to convert a list into
> a function call agruments?

Jeff Epler already answered to the question. Now a couple of advices:

> For example:
> 
> list = (2005, 5, 5)

1/ this is not a list, it's a tuple. A list would be [2005, 5, 5]. (BTW, 
it's quite ok - and even better imho - to use a tuple here)

2/ using the word 'list' as identifier shadows the builtin function 
'list'. This is allowed, but you may prefer to avoid doing so.

3/ also, using the word 'list' as an identifier here is a poor choice 
from a semantic POV, since it convey useless (and in this case wrong) 
informations about an implementation detail (the data structure type) 
but says nothing about the intended use of the data. Something like 
'the_date' would have been better IMHO.

My 2 cents
-- 
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for 
p in 'onurb at xiludom.gro'.split('@')])"



More information about the Python-list mailing list