Re: Why is "unpacking" of tuples only allowed when there's 1 tupple ?

Discussion in 'Python' started by Stef Mientki, Aug 15, 2009.

  1. Stef Mientki

    Stef Mientki Guest

    thanks Jan,
    for the clear explanation.
    cheers,
    Stef

    Jan Kaliszewski wrote:
    > Dnia 15-08-2009 o 22:50:39 Stef Mientki <>
    > napisał(a):
    >
    >> hello,
    >>
    >> 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[0], filt[1] )
    >>
    >> 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[0], Polynome[1], 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
    >
     
    Stef Mientki, Aug 15, 2009
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,222
    Smokey Grindel
    Dec 2, 2006
  2. Stef Mientki
    Replies:
    0
    Views:
    291
    Stef Mientki
    Aug 15, 2009
  3. Ross
    Replies:
    15
    Views:
    696
    Vlastimil Brom
    Sep 22, 2009
  4. joblack
    Replies:
    2
    Views:
    596
  5. Jon Reyes
    Replies:
    18
    Views:
    271
    Mitya Sirenef
    Feb 19, 2013
Loading...

Share This Page