[Python-Dev] Re: Python-checkins digest, Vol 1 #370 - 8 msgs

Fredrik Lundh Fredrik Lundh" <effbot@telia.com
Tue, 29 Feb 2000 09:00:45 +0100


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.)
>=20
> [David Ascher]
> > I think you're responsible for a little bit of the confusion.
> <about append working being documentation enough>
>=20
> 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 =3D 1, 2, 3" vs. "a =3D (1, 2, 3)"
    "a, b, c =3D a" vs. "(a, b, c) =3D a"
    "a[a, b, c]" vs. "a[(a, b, c)]"
   =20
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)] =3D [x]  =20

    s.extend(x) -> same as s[len(s):len(s)] =3D x
    (raise exception if x is not a list)

    a[k] -> the item of a with key k=20

    a[k] =3D x -> set a[k] to x

...

but now that we have appendnanny, I don't really mind...

</F>