Multi-argument append() is illegal

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/) -- ----------- comp.lang.python.announce (moderated) ---------- Article Submission Address: python-announce@python.org Python Language Home Page: http://www.python.org/ Python Quick Help Index: http://www.python.org/Help.html ------------------------------------------------------------
participants (1)
-
Guido van Rossum