
Moshe Zadka wrote:
[Guido]
If it's not in the docs, where does everybody get the idea that this is legal? (The few cases in the std library are unlikely to be the only source; they were in pretty obscure places.)
[David Ascher]
I think you're responsible for a little bit of the confusion. <about append working being documentation enough>
David, you're taking Guido out of context: he did not say the "append" was bad style, but that the "too inclusive excpetion" is bad style.
yeah, but it wasn't, in this case -- the problem here is that you've added TypeError to the list of exceptions that append may raise, and that it does so on code that works perfectly fine under 1.5.2. ... David points out that Python lets you leave out the parens around tuples in lots of places. consider: "a = 1, 2, 3" vs. "a = (1, 2, 3)" "a, b, c = a" vs. "(a, b, c) = a" "a[a, b, c]" vs. "a[(a, b, c)]" IOW, expecting 'append' to do what it did before is perfectly reasonable (especially given 'extend'), also if you consider what the library reference says: s.append(x) -> same as s[len(s):len(s)] = [x] s.extend(x) -> same as s[len(s):len(s)] = x (raise exception if x is not a list) a[k] -> the item of a with key k a[k] = x -> set a[k] to x ... but now that we have appendnanny, I don't really mind... </F>