Typo in Python Tutorial?

chris liechti cliechti at mails.ch
Tue Aug 14 22:29:14 CEST 2001

[posted and mailed]

rupe at metro.yak.net (Rupert Scammell) wrote in 
news:79179cf5.0108141146.1ce6e2ee at posting.google.com:
> In the Python Tutorial
> (http://www.python.org/doc/current/tut/tut.html), Section 5.1, I
> noticed that the pop() method for lists is documented as:
> pop([i])
> Remove the item at the given position in the list, and return it. If
> no index is specified, a.pop() returns the last item in the list. The
> item is also removed from the list.
> I tried the following:
>>>> mylist = ['one','two','three'] list_item = mylist.pop([0])
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
> TypeError: an integer is required

the "[]" are there to indicate an optional argument not a python list.
this means that you can use pop with either no argument or an integer which 
specifies which element to pop.

if you compare it with 
you will see that optional args are indicated with bold brackets to make a 
clear distinction to python lists.

chris <cliechti at mails.ch>

More information about the Python-list mailing list