[Zope-dev] Fwd: Multi-argument append() is illegal
Patrick Phalen
zope@teleo.net
Wed, 1 Mar 2000 11:44:59 -0800
Fredrik Lundh has mentioned that this breaks Zope (and Medusa).
If so, it's probably not too soon to begin looking into it. 1.6 is due
this summer.
---------- ## Forwarded Message ## ----------
Subject: Multi-argument append() is illegal
Date: Mon, 28 Feb 2000 10:41:02 -0500
From: Guido van Rossum <guido@python.org>
I've noticed that there is some code out there that creates a list of
tuples and uses code like list.append(a,b,c) to add the tuple (a,b,c)
to the list. According to the documentation, this is illegal:
append() only takes a single argument, and one should write
list.append((a,b,c)). However, the actual append() implementation
didn't mind, and implemented list.append(a,b,c) as
list.append((a,b,c)). Many people are using this even though it's
never been documented.
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 message is simply a heads-up that you should be aware of this
change (when 1.6 comes out, which should be before the summer). You
can test your programs using the current CVS version (see
www.python.org/download/cvs.html). You can also grep through your
sources for a pattern like "\. *append *\(.*," -- which doesn't find
every occurrence, but is a good starting point. If you have a smarter
grep-like tool you may be able to write a tighter matching expression.
Watch out for false hits though: some classes define their own
multi-argument append()...
--Guido van Rossum (home page: http://www.python.org/~guido/)
--
http://www.python.org/mailman/listinfo/python-list
-------------------------------------------------------