Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55ad7f8

Browse files
committed
Completely revise markup for the list of list methods; the new markup matches
the semantics and presentation used in the library reference. Added an explanation of the use of [...] to denote optional arguments, since this is the only use of this in a signature line. Closes SF bug #567127.
1 parent 9f7549b commit 55ad7f8

1 file changed

Lines changed: 35 additions & 26 deletions

File tree

Doc/tut/tut.tex

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1618,45 +1618,54 @@ \section{More on Lists \label{moreLists}}
16181618
The list data type has some more methods. Here are all of the methods
16191619
of list objects:
16201620

1621-
\begin{description}
1622-
1623-
\item[\code{append(x)}]
1621+
\begin{methoddesc}[list]{append}{x}
16241622
Add an item to the end of the list;
1625-
equivalent to \code{a[len(a):] = [x]}.
1623+
equivalent to \code{a[len(a):] = [\var{x}]}.
1624+
\end{methoddesc}
16261625

1627-
\item[\code{extend(L)}]
1626+
\begin{methoddesc}[list]{extend}{L}
16281627
Extend the list by appending all the items in the given list;
1629-
equivalent to \code{a[len(a):] = L}.
1630-
1631-
\item[\code{insert(i, x)}]
1632-
Insert an item at a given position. The first argument is the index of
1633-
the element before which to insert, so \code{a.insert(0, x)} inserts at
1634-
the front of the list, and \code{a.insert(len(a), x)} is equivalent to
1635-
\code{a.append(x)}.
1636-
1637-
\item[\code{remove(x)}]
1638-
Remove the first item from the list whose value is \code{x}.
1628+
equivalent to \code{a[len(a):] = \var{L}}.
1629+
\end{methoddesc}
1630+
1631+
\begin{methoddesc}[list]{insert}{i, x}
1632+
Insert an item at a given position. The first argument is the index
1633+
of the element before which to insert, so \code{a.insert(0, \var{x})}
1634+
inserts at the front of the list, and \code{a.insert(len(a), \var{x})}
1635+
is equivalent to \code{a.append(\var{x})}.
1636+
\end{methoddesc}
1637+
1638+
\begin{methoddesc}[list]{remove}{x}
1639+
Remove the first item from the list whose value is \var{x}.
16391640
It is an error if there is no such item.
1641+
\end{methoddesc}
16401642

1641-
\item[\code{pop(\optional{i})}]
1643+
\begin{methoddesc}[list]{pop}{\optional{i}}
16421644
Remove the item at the given position in the list, and return it. If
16431645
no index is specified, \code{a.pop()} returns the last item in the
1644-
list. The item is also removed from the list.
1645-
1646-
\item[\code{index(x)}]
1647-
Return the index in the list of the first item whose value is \code{x}.
1646+
list. The item is also removed from the list. (The square brackets
1647+
around the \var{i} in the method signature denote that the parameter
1648+
is optional, not that you should type square brackets at that
1649+
position. You will see this notation frequently in the
1650+
\citetitle[../lib/lib.html]{Python Library Reference}.)
1651+
\end{methoddesc}
1652+
1653+
\begin{methoddesc}[list]{index}{x}
1654+
Return the index in the list of the first item whose value is \var{x}.
16481655
It is an error if there is no such item.
1656+
\end{methoddesc}
16491657

1650-
\item[\code{count(x)}]
1651-
Return the number of times \code{x} appears in the list.
1658+
\begin{methoddesc}[list]{count}{x}
1659+
Return the number of times \var{x} appears in the list.
1660+
\end{methoddesc}
16521661

1653-
\item[\code{sort()}]
1662+
\begin{methoddesc}[list]{sort}{}
16541663
Sort the items of the list, in place.
1664+
\end{methoddesc}
16551665

1656-
\item[\code{reverse()}]
1666+
\begin{methoddesc}[list]{reverse}{}
16571667
Reverse the elements of the list, in place.
1658-
1659-
\end{description}
1668+
\end{methoddesc}
16601669

16611670
An example that uses most of the list methods:
16621671

0 commit comments

Comments
 (0)