Re: passing variable length arguments without unpacking them

Tim Peters (tim@ksr.com)
Tue, 26 Jan 93 22:36:19 EST

You're welcome, Jaap! I'm happy if it solved your problem.

> ...
> I was thrown off by the non-intuitive fact that a tuple *will* get
> unpacked when assigned to formal arguments directly, i.e.:
>
> >>> def fun1(arg1, arg2):
> ... pass
> ...
> >>> fun1((1, 2))
> >>>
>
> works like a champ. I guess this is for backwards compatibility.

Speaking of remembering you've seen something but can't quite recall
where, I just found this (again) in python-NEWS-0.9.8:

> (There's a third compatibility hack, which is the reverse of (a): if a
> function is defined with two or more arguments, and called with a
> single argument that is a tuple with just as many arguments, the items
> of this tuple will be used as the arguments. Although this can (and
> should!) be done using the built-in function apply() instead, it isn't
> withdrawn yet.)

So, as usual, Guido addressed all our questions long before we thought of
them <grin>.

Maybe this is cause for hope: Python has tried a few sets of rules for
dealing with tuples vs arglists, and for getting the effect of variable
argument lists, & I believe 0.9.8's rules are the first set I feel I can
predict in all cases without "looking it up" once a week (of course I'm
talking about the documented rules -- the reference manual doesn't claim
you can get away with the example above).

so-it-feels-like-progress-to-me-ly y'rs - tim

Tim Peters tim@ksr.com
not speaking for Kendall Square Research Corp