forwarding *arg parameter

Tuomas tuomas.vesterinen at pp.inet.fi
Sun Nov 5 19:00:30 CET 2006


Tuomas wrote:
> def g(*arg):
>     return arg
> 
> def f(*arg):
>     return g(arg)
> 
> How can g know if it is called directly with (('foo', 'bar'),) or via f 
> with ('foo', 'bar'). I coud write in f: return g(arg[0], arg[1]) if I 
> know the number of arguments, but what if I don't know that in design time?

So it seems that I would like to have an unpack operator:

def f(*arg):
     return(!*arg)

TV



More information about the Python-list mailing list