From: Jonathan Fine on
The idioms
def f(*args, **kwargs):
# Do something.
args = (1, 2, 3)
kwargs = dict(a=4, b=5)
g(*args, **kwargs)
are often useful in Python.

I'm finding myself picking up /all/ the arguments and storing them for
later use (as part of a testing framework). So for me it would be nice
if I could write
def f(***allargs):
args, kwargs = allargs
# Continue as before.

However, if we do this then 'args' in '*args' is misleading. So I'll
use 'sargs' (for sequence arguments) instead.

I can now write, for a suitable class Args
args = Args(1, 2, 3, a=4, b=5)
g(***args) # Same as before.
sargs, kwargs = args
g(*sargs, **kwargs) # Same as before.

Even better, now that Args is a class we can give it a method 'call' so that
is equivalent to
which removes the need for the *** construct.

This reminds me of functools.partial except, of course, we've fixed all
the arguments and left the passing of the function for later, whereas in
partial we fix the function and some of the arguments.

My view are that
1. Conceptually ***allargs is useful, but an Args class would be more
useful (not that it need be either-or).

2. If Args were built in , there could be performance benefits.

3. It's clearer to write
def(*seqargs, **kwargs):
def(*args, **kwargs):

4. When the Args class is used a lot, one might welcome
# Do something with args.
as a shortcut (and minor speedup) for
def(*seqargs, **kwargs):
args = Args(*seqargs, **kwargs)
# Do something with args.

I look forward to your comments on this.