Multi-argument append() is illegal

Gordon McMillan gmcm at hypernet.com
Mon Feb 28 21:36:12 EST 2000


Alexander Williams wrote:

> On Mon, 28 Feb 2000 10:41:02 -0500, Guido van Rossum <guido at python.org> wrote:
> >I am going to rectify this in Python 1.6 -- people coming from other
> >languages might well expect list.append(a, b, c) to mean the same as
> >list.append(a); list.append(b); list.append(c), and it's always been
> >my philosophy to make ambiguous syntax illegal rather than to pick one
> >interpretation randomly.
> 
> This would seem to violate the Principal of Least Surprise, at least
> when considering the rest of the language.  Unless you also start
> requiring the presence of parens on every other construction of a
> tuple (as in:
> 
>    >>> a, b, c = string.split("1 2 3")
> 
> ) you're introducing inconsistancy with Python in general.

Hardly. The only way to make f(a,b,...) identical to f((a,b,...)) 
for an arbitrary number of args is to play games with *args in f. 
The fact that it happens to work with append right now is the 
inconsistancy.

- Gordon




More information about the Python-list mailing list