Gary Herron wrote: > samwyse wrote: > >>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. >> > > Well, your moreargs parameter is a tuple, and there are innumerable ways > to process a tuple. (And even more if you convert it to a list.)
My use-case is (roughtly) this: first, *rest = f.readline().split() return dispatch_table{first}(*rest) -- http://mail.python.org/mailman/listinfo/python-list