Why not f(*my_list, *my_other_list) ?

I noticed that it's impossible to call a Python function with two starred argument lists, like this: `f(*my_list, *my_other_list)`. I mean, if someone wants to feed two lists of arguments into a function, why not? I understand why you can't have two stars in a function definition; But why can't you have two (or more) stars in a function call? Ram.

On Fri, Sep 10, 2010 at 06:37:44PM +0200, cool-RR wrote:
f(*my_list, *my_other_list)
Not every one-lined should be a syntax. Just call f(*(my_list + my_other_list)) Oleg. -- Oleg Broytman http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.

cool-RR <cool-rr@...> writes:
I noticed that it's impossible to call a Python function with two starred
argument lists, like this: `f(*my_list, *my_other_list)`. I mean, if someone wants to feed two lists of arguments into a function, why not? Okay, so why would you want to?

Benjamin Peterson, 10.09.2010 19:03:
Well, it can happen. It doesn't merit a syntax extension, though. You can just do args_for_f = tuple(my_list) + tuple(my_other_list) f(*args_for_f) (using tuple() here in case both are not really lists) Stefan

On Fri, Sep 10, 2010 at 12:16 PM, Stefan Behnel <stefan_ml@behnel.de> wrote:
args_for_f = tuple(my_list) + tuple(my_other_list) f(*args_for_f)
An alternative with better performance is: from itertools import chain f(*chain(my_list, my_other_list)) -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>

Em Fri, 10 Sep 2010 18:37:44 +0200 cool-RR <cool-rr@cool-rr.com> escreveu:
How the compiler should treat that? Put half of the arguments in the first list and the other half on the second list? Regards, -- .:''''':. .:' ` Sérgio Surkamp | Gerente de Rede :: ........ sergio@gruposinternet.com.br `:. .:' `:, ,.:' *Grupos Internet S.A.* `: :' R. Lauro Linhares, 2123 Torre B - Sala 201 : : Trindade - Florianópolis - SC :.' :: +55 48 3234-4109 : ' http://www.gruposinternet.com.br

On 9/10/2010 12:37 PM, cool-RR wrote:
Beyond 0. Not needed as others explained, some speculations: 1. Calls are designed to mirror definition. No multiple stars in definition means no multiple stars in calls. 2. Multiple stars begin to look like typing errors. 3. No one ever thought to support such. 4. It would make the call process even more complex, and it is slow enough already. 5. It might conflict with the current implementation. -- Terry Jan Reedy

On Fri, Sep 10, 2010 at 06:37:44PM +0200, cool-RR wrote:
f(*my_list, *my_other_list)
Not every one-lined should be a syntax. Just call f(*(my_list + my_other_list)) Oleg. -- Oleg Broytman http://phd.pp.ru/ phd@phd.pp.ru Programmers don't die, they just GOSUB without RETURN.

cool-RR <cool-rr@...> writes:
I noticed that it's impossible to call a Python function with two starred
argument lists, like this: `f(*my_list, *my_other_list)`. I mean, if someone wants to feed two lists of arguments into a function, why not? Okay, so why would you want to?

Benjamin Peterson, 10.09.2010 19:03:
Well, it can happen. It doesn't merit a syntax extension, though. You can just do args_for_f = tuple(my_list) + tuple(my_other_list) f(*args_for_f) (using tuple() here in case both are not really lists) Stefan

On Fri, Sep 10, 2010 at 12:16 PM, Stefan Behnel <stefan_ml@behnel.de> wrote:
args_for_f = tuple(my_list) + tuple(my_other_list) f(*args_for_f)
An alternative with better performance is: from itertools import chain f(*chain(my_list, my_other_list)) -- Daniel Stutzbach, Ph.D. President, Stutzbach Enterprises, LLC <http://stutzbachenterprises.com>

Em Fri, 10 Sep 2010 18:37:44 +0200 cool-RR <cool-rr@cool-rr.com> escreveu:
How the compiler should treat that? Put half of the arguments in the first list and the other half on the second list? Regards, -- .:''''':. .:' ` Sérgio Surkamp | Gerente de Rede :: ........ sergio@gruposinternet.com.br `:. .:' `:, ,.:' *Grupos Internet S.A.* `: :' R. Lauro Linhares, 2123 Torre B - Sala 201 : : Trindade - Florianópolis - SC :.' :: +55 48 3234-4109 : ' http://www.gruposinternet.com.br

On 9/10/2010 12:37 PM, cool-RR wrote:
Beyond 0. Not needed as others explained, some speculations: 1. Calls are designed to mirror definition. No multiple stars in definition means no multiple stars in calls. 2. Multiple stars begin to look like typing errors. 3. No one ever thought to support such. 4. It would make the call process even more complex, and it is slow enough already. 5. It might conflict with the current implementation. -- Terry Jan Reedy
participants (9)
-
Benjamin Peterson
-
cool-RR
-
Daniel Stutzbach
-
Mike Graham
-
MRAB
-
Oleg Broytman
-
Stefan Behnel
-
Sérgio Surkamp
-
Terry Reedy