Re: variable length tuple assignment

2009-02-25 Thread Steven D'Aprano
Tim Chase wrote: > As an aside, as of the last time I read the PEP[1] on this, I > believe it exhausts (or attempts to exhaust) any iterator. IMHO, > I think this exhausting is a bad idea because it prevents things like > >def numbers(start=0): > i = start > while True: >yi

Re: variable length tuple assignment

2009-02-25 Thread Tim Chase
Chris Rebert wrote: On Wed, Feb 25, 2009 at 1:16 AM, Helmut Jarausch wrote: Sorry if this is too simple but I couldn't find. I vaguely remember there is a means to assign a variable length tuple and catch the 'rest' like S="a,b,c,d" (A,B,) = S.split(',') In Python 3.0 (IIRC): A, B, *rest

Re: variable length tuple assignment

2009-02-25 Thread Chris Rebert
On Wed, Feb 25, 2009 at 1:16 AM, Helmut Jarausch wrote: > Sorry if this is too simple but I couldn't find. > > I vaguely remember there is a means to assign a variable length tuple > and catch the 'rest'  like > > S="a,b,c,d" > > (A,B,) = S.split(',') In Python 3.0 (IIRC): A, B, *rest = S.split(

variable length tuple assignment

2009-02-25 Thread Helmut Jarausch
Sorry if this is too simple but I couldn't find. I vaguely remember there is a means to assign a variable length tuple and catch the 'rest' like S="a,b,c,d" (A,B,) = S.split(',') I know I could do SL= split(',') (A,B)=SL[:2] Rest= SL[2:] but is there some shorthand for this? Many thanks for