Detupleize a tuple for argument list
Bruno Desthuilliers
onurb at xiludom.gro
Wed Jul 5 09:22:07 EDT 2006
Marco Wahl wrote:
>>Marco Wahl enlightened us with:
>>
>>>>>>foo(t)
>>>
>>> Traceback (most recent call last):
>>> File "<stdin>", line 1, in ?
>>> TypeError: foo() takes exactly 2 arguments (1 given)
>>
>>Call foo(*t)
>
>
> Thank you very much Luke Plant, Steven D'Aprano and Sybren Stuvel.
>
> This was exactly what I was looking for. I'm happy now. ;-)
FWIW, there's something similar for dicts and named args:
>>> def foo(a, b): print str(a), str(b)
...
>>> kwargs = {'a' : 1, 'b': 2}
>>> foo(**kwargs)
1 2
>>>
--
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