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
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
[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
[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
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
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
[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