Errata: Typo in Python Tutorial

Alex Martelli aleaxit at yahoo.com
Tue Aug 14 17:32:48 EDT 2001


"Rupert Scammell" <rupe at metro.yak.net> wrote in message
news:79179cf5.0108141202.14390c71 at posting.google.com...
> I wish I had a net-torpedo sometimes, that would catch errant posts as
> they sped towards an uncountable number of Usenet servers.
>
> My confusion about the pop() method for lists in my last post was one
> of incorrectly interpreted notation.  I interpreted the [0] notation
> in s.pop([0]) as representing a single item list object, rather than
> just the notation for an optional parameter to the method.
>
> Sorry 'bout that.

A very natural error to make!  When feasible (it almost always
is, but not always, sigh) I prefer to indicate default argument by
Python-ish syntax, rather than the [] meta-syntax that lends
itself to confusion with the brackets of Python itself.  So, e.g.,
I'd present the pop method, for example, as:

    s.pop(i=-1)    same as x = s[i]; del s[i]; return x

But, alas, the brackets are traditional (and, double alas,
sometimes there IS no 'argument default value' that is
truly equivalent to the total lack of an argument... e.g,
the getattr builtin -- there's no value one can pass as
the 3rd argument to make it behave as it does when
it's called with only 2 arguments).


Alex






More information about the Python-list mailing list