Why is "unpacking" of tuples only allowed when there's 1 tupple ?
stef.mientki at gmail.com
Sat Aug 15 23:19:53 CEST 2009
for the clear explanation.
Jan Kaliszewski wrote:
> Dnia 15-08-2009 o 22:50:39 Stef Mientki <stef.mientki at gmail.com>
>> I'm not sure if "unpacking" is the right term
>> but if I have a tuple of 2 arrays,
>> I can either call a function with:
>> Space_State = tf2ss ( filt, filt )
>> or with
>> Space_State = tf2ss ( *filt )
>> Now if I've to call a function with more parameters,
>> why can't I use (Polynome is again a tuple of 2 arrays) :
>> (which already gives an error in the IDE)
>> Respons = signal.lfilter ( *Polynome, Signal )
>> and thus I've to use:
>> Respons = signal.lfilter ( Polynome, Polynome, Signal )
> The content of that tuple or list (filt/Polynome here) doesn't matter.
> Simply, when calling function, you can't put positional (non-keyword)
> argument after *something.
> >>> def nic(*args, **kwargs): pass
> >>> nic(*[1,2,3], 4)
> File "<stdin>", line 1
> SyntaxError: only named arguments may follow *expression
> That'd be ok:
> Respons = signal.lfilter(*Polynome, sig=Signal) # if this method can
> # receive argument
> # 'sig' after more
> # than len(Polynome)
> # of arguments
More information about the Python-list