Re: passing/catching a variable number of args in python

Daniel LaLiberte (liberte@ncsa.uiuc.edu)
Thu, 12 Dec 91 11:02:34 CST

You did a fine job: you've convinced me that there is a way to change
Python's argument passing without breaking the whole language, and
allowing several problems with arguments to be fixed.

Well, I'm glad we persisted then. But from your counter proposal, my
main contribution seems to be rule 1. I would also, over time, do away
with rules 2 and 3, which seem to exist mostly for backward compatibility.
I would try to provide their unique features in some other way;
in Lisp, rule 2 would be replaced by using apply and rule 3 by &rest args.

I don't think it is necessary to change assignments at all.

No, it isn't necessary, just more consistent. But given rules 2 and 3,
doing "a = 1, 2, 3" and "a, b, c = (1, 2, 3)" is consistent.

Now I have to get back to your mail.

>def f((x), y)
>
>f((1), 2) -- x gets 1
>f((1, 2), 3) -- this I don't like. should x get tuple (1, 2)? I say no.
> -- an error would be more consistent. what does python do?

Currently "def f((x), y)" is indistinguishable from "def f(x, y)",
just as "(1)+1" is indistinguishable from "1+1". I'd like to keep
this rule in general. My proposal above only makes the outermost
parentheses of function calls and declarations special.

OK, how about def f((x, ), y) then?

>Had you considered matching corresponding elements of lists too?
>So def f([a, b]) could be given f([1, 2]).

Not too useful, since lists are mostly used when they may vary in
length.

Well, granted my suggestion above is not too useful by itself.
But if lists vary in length, then it would be more useful to have
a way of matching all remaining elements of a list.

Feel free to use any of my mail in a summary to the python list if
you wish.

dan