WANTED: A good name for the pair (args, kwargs)

J

Jonathan Fine

Hi

We can call a function fn using
val = fn(*args, **kwargs)

I'm looking for a good name for the pair (args, kwargs). Any suggestions?

Here's my use case:
def doit(fn , wibble, expect):
args, kwargs = wibble
actual = fn(*args, **kwargs)
if actual != expect:
# Something has gone wrong.
pass

This is part of a test runner.

For now I'll use argpair, but if anyone has a better idea, I'll use it.
 
T

Tim Chase

Jonathan said:
We can call a function fn using
val = fn(*args, **kwargs)

I'm looking for a good name for the pair (args, kwargs). Any suggestions?

For now I'll use argpair, but if anyone has a better idea, I'll use it.

In the legacy of C and Java (okay, that doesn't carry _much_
weight with me), I'd go with "varargs" to refer to the pair of
(args, kwargs)

-tkc
 
P

Paul Rubin

Jonathan Fine said:
I'm looking for a good name for the pair (args, kwargs). Any suggestions?

Here's my use case:
def doit(fn , wibble, expect):
args, kwargs = wibble
actual = fn(*args, **kwargs)

I think this may have been broken in 3.x, but in 2.6 the compiler will
unpack directly if you put a tuple structure in the arg list:

def doit(fn, (args, kwargs), expect):
actual = fn(*args, **kwargs)

Otherwise I'd just say "all_args" or some such. Or just "args" which
you unpack into "pos_args" (positional args) and "kw_args".
 
S

Steve Holden

Jonathan said:
Hi

We can call a function fn using
val = fn(*args, **kwargs)

I'm looking for a good name for the pair (args, kwargs). Any suggestions?

Here's my use case:
def doit(fn , wibble, expect):
args, kwargs = wibble
actual = fn(*args, **kwargs)
if actual != expect:
# Something has gone wrong.
pass

This is part of a test runner.

For now I'll use argpair, but if anyone has a better idea, I'll use it.
Not being able to find any existing names I called *args the
sequence-parameter and **kwarg the dict-parameter.

For your use, though, you might choose something like the "generic
parameter pair).

regards
Steve
 
A

Aahz

In the legacy of C and Java (okay, that doesn't carry _much_ weight
with me), I'd go with "varargs" to refer to the pair of (args, kwargs)

Ditto
--
Aahz ([email protected]) <*> http://www.pythoncraft.com/

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer
 
J

Jonathan Fine

Jonathan said:
Hi

We can call a function fn using
val = fn(*args, **kwargs)

I'm looking for a good name for the pair (args, kwargs). Any suggestions?

Here's my use case:
def doit(fn , wibble, expect):
args, kwargs = wibble
actual = fn(*args, **kwargs)
if actual != expect:
# Something has gone wrong.
pass

This is part of a test runner.

For now I'll use argpair, but if anyone has a better idea, I'll use it.

Thank you, Tim, Paul, Steve and Aahz for your suggestions.

I'm now preferring:

def test_apply(object, argv, valv):

args, kwargs = argv
expect, exceptions = valv

# Inside try: except:
actual = object(*args, **kwargs)

# Check against expect, exceptions.

best regards


Jonathan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top