S
samwyse
I'm a relative newbie to Python, so please bear with me. After seeing
how varargs work in parameter lists, like this:
def func(x, *arglist):
and this:
x = func(1, *moreargs)
I thought that I'd try this:
first, *rest = arglist
Needless to say, it didn't work. That leaves me with two questions.
First, is there a good way to do this? For now, I'm using this:
first, rest = arglist[0], arglist[1:]
but it leaves a bad taste in my mouth.
Second, is there any good reason why it shouldn't work? It seems like
such an obvious idiom that I can't believe that I'm the first to come up
with the idea. I don't really have the time right now to go source
diving, so I can't tell if it would be wildly inefficient to implement.
Thanks!
how varargs work in parameter lists, like this:
def func(x, *arglist):
and this:
x = func(1, *moreargs)
I thought that I'd try this:
first, *rest = arglist
Needless to say, it didn't work. That leaves me with two questions.
First, is there a good way to do this? For now, I'm using this:
first, rest = arglist[0], arglist[1:]
but it leaves a bad taste in my mouth.
Second, is there any good reason why it shouldn't work? It seems like
such an obvious idiom that I can't believe that I'm the first to come up
with the idea. I don't really have the time right now to go source
diving, so I can't tell if it would be wildly inefficient to implement.
Thanks!