[Python-ideas] Why not f(*my_list, *my_other_list) ?

Stefan Behnel stefan_ml at behnel.de
Fri Sep 10 19:13:42 CEST 2010

Ian Kelly, 10.09.2010 19:03:
> On Fri, Sep 10, 2010 at 10:52 AM, MRAB<python at mrabarnett.plus.com>  wrote:
>> On 10/09/2010 17:37, cool-RR wrote:
>>> 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?
>> Would there be any advantage over `f(*(my_list + my_other_list))`?
> That fails if my_list and my_other_list are different types, whereas
> the *args syntax happily accepts any iterable object.

But I think it's still a rare enough use case to require

     f(*(tuple(my_list) + tuple(my_other_list)))

when you need it, although the concatenation would likely get split up and 
moved into an explicit variable anyway.


More information about the Python-list mailing list