forwarding *arg parameter

Diez B. Roggisch deets at nospam.web.de
Sun Nov 5 10:41:22 EST 2006


Tuomas schrieb:
>  >>> def g(*arg):
> ...     return arg
> ...
>  >>> g('foo', 'bar')
> ('foo', 'bar')
>  >>> # seems reasonable
> ...
>  >>> g(g('foo', 'bar'))
> (('foo', 'bar'),)
>  >>> # not so good, what g should return to get rid of the outer tuple

g(*g('foo', 'bar'))


* and **  are the symetric - they capture ellipsis arguments, and they 
make iterables/dicts passed as positional/named arguments.

Diez



More information about the Python-list mailing list