Flatten a list/tuple and Call a function with tuples
steve at REMOVE.THIS.cybersource.com.au
Thu Jul 26 03:21:22 CEST 2007
On Wed, 25 Jul 2007 15:46:58 +0000, beginner wrote:
> I know the * operator. However, a 'partial unpack' does not seem to
> def g():
> return (1,2)
> def f(a,b,c):
> return a+b+c
> f(*g(),10) will return an error.
No it doesn't, it _raises_ an exception. This is a function that returns
"""Returns an error."""
return Error() # defined elsewhere
But to answer your question:
> Do you know how to get that to work?
It's a little bit messy, but this works:
>>> f(*(g() + (10,)))
This is probably easier to read:
>>> t = g() + (10,); f(*t)
More information about the Python-list