Re: Splice two lists

2006-05-07 Thread [EMAIL PROTECTED]
When used in a function call (as opposed to a function definition), * is the unpacking operator. Basically, it flattens an iterable into arguments. The docs mention it... Cool, looks like I didn't read carefully enough. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list

Splice two lists

2006-05-06 Thread [EMAIL PROTECTED]
Is there a good way to splice two lists together without resorting to a manual loop? Say I had 2 lists: l1 = [a,b,c] l2 = [1,2,3] And I want a list: [a,1,b,2,c,3] as the result. I've been searching around but I can't seem to find a good example. Thanks, Dan McLeran -- http

Re: Splice two lists

2006-05-06 Thread Alex Martelli
[EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Is there a good way to splice two lists together without resorting to a manual loop? Say I had 2 lists: l1 = [a,b,c] l2 = [1,2,3] And I want a list: [a,1,b,2,c,3] as the result. I've been searching around but I can't seem to find a good

Re: Splice two lists

2006-05-06 Thread Ben Cartwright
[EMAIL PROTECTED] wrote: Is there a good way to splice two lists together without resorting to a manual loop? Say I had 2 lists: l1 = [a,b,c] l2 = [1,2,3] And I want a list: [a,1,b,2,c,3] as the result. Our good friend itertools can help us out here: from itertools import chain, izip

Re: Splice two lists

2006-05-06 Thread Michael J. Fromberger
In article [EMAIL PROTECTED], [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Is there a good way to splice two lists together without resorting to a manual loop? Say I had 2 lists: l1 = [a,b,c] l2 = [1,2,3] And I want a list: [a,1,b,2,c,3] as the result. I've been searching around

Re: Splice two lists

2006-05-06 Thread [EMAIL PROTECTED]
Thanks, this worked great. Can you explain the syntax of the '*' on the return value of izip? I've only ever seen this syntax with respect to variable number of args. Thanks again. -- http://mail.python.org/mailman/listinfo/python-list

Re: Splice two lists

2006-05-06 Thread Ben Cartwright
[EMAIL PROTECTED] wrote: Thanks, this worked great. Welcome. :-) Can you explain the syntax of the '*' on the return value of izip? I've only ever seen this syntax with respect to variable number of args. When used in a function call (as opposed to a function definition), * is the unpacking