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

Daniel LaLiberte (liberte@ncsa.uiuc.edu)
Fri, 6 Dec 91 10:19:04 CST

A different approach would appear to *always* make function arguments
a tuple. This would pass single arguments as singleton tuples, making
f(1) equivalent to f(1,). However, this doesn't fly: in the current
situation, you can write x = (1,2,3) and later call f(x) with exactly
the same result as f(1,2,3). In the alternate approach, f(x) would be
turned into f(x,), and would no longer be equivalent to f(1,2,3). So
either way you lose.

You could support calling f(x) by using a separate kind of function call,
analogous to Lisp apply. f(x) as compared with f(1, 2, 3) really does
a different thing internally, and it was confusing to me as a
new user to discover that these were intended to have the same result.

Maybe you want to consider calling f with arguments being the elements
of the tuple x using the syntax "f x". Then "f (1, 2, 3)" is really
the same kind of function call as "f x". This may be inconsistent with other
aspects of the Python syntax; I dont have my grammar handy.

Dan LaLiberte
National Center for Supercomputing Applications

liberte@ncsa.uiuc.edu
(Join the League for Programming Freedom: league@prep.ai.mit.edu)