-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
gh-144837: Improve documentation for more collection methods #144841
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
af815fb
adc4bef
e0fe9c7
d52b8fa
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,35 +15,35 @@ More on Lists | |
| The :ref:`list <typesseq-list>` data type has some more methods. Here are all | ||
| of the methods of list objects: | ||
|
|
||
| .. method:: list.append(x) | ||
| .. method:: list.append(value, /) | ||
serhiy-storchaka marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| :noindex: | ||
|
|
||
| Add an item to the end of the list. Similar to ``a[len(a):] = [x]``. | ||
|
|
||
|
|
||
| .. method:: list.extend(iterable) | ||
| .. method:: list.extend(iterable, /) | ||
| :noindex: | ||
|
|
||
| Extend the list by appending all the items from the iterable. Similar to | ||
| ``a[len(a):] = iterable``. | ||
|
|
||
|
|
||
| .. method:: list.insert(i, x) | ||
| .. method:: list.insert(index, value, /) | ||
| :noindex: | ||
|
|
||
| Insert an item at a given position. The first argument is the index of the | ||
| element before which to insert, so ``a.insert(0, x)`` inserts at the front of | ||
| the list, and ``a.insert(len(a), x)`` is equivalent to ``a.append(x)``. | ||
|
|
||
|
|
||
| .. method:: list.remove(x) | ||
| .. method:: list.remove(value, /) | ||
| :noindex: | ||
|
|
||
| Remove the first item from the list whose value is equal to *x*. It raises a | ||
| Remove the first item from the list whose value is equal to *value*. It raises a | ||
| :exc:`ValueError` if there is no such item. | ||
|
|
||
|
|
||
| .. method:: list.pop([i]) | ||
| .. method:: list.pop(index=-1, /) | ||
| :noindex: | ||
|
|
||
| Remove the item at the given position in the list, and return it. If no index | ||
|
|
@@ -58,10 +58,10 @@ of the methods of list objects: | |
| Remove all items from the list. Similar to ``del a[:]``. | ||
|
|
||
|
|
||
| .. method:: list.index(x[, start[, end]]) | ||
| .. method:: list.index(value[, start[, stop]) | ||
|
||
| :noindex: | ||
|
|
||
| Return zero-based index of the first occurrence of *x* in the list. | ||
| Return zero-based index of the first occurrence of *value* in the list. | ||
| Raises a :exc:`ValueError` if there is no such item. | ||
|
|
||
| The optional arguments *start* and *end* are interpreted as in the slice | ||
|
|
@@ -70,10 +70,10 @@ of the methods of list objects: | |
| sequence rather than the *start* argument. | ||
|
|
||
|
|
||
| .. method:: list.count(x) | ||
| .. method:: list.count(value, /) | ||
| :noindex: | ||
|
|
||
| Return the number of times *x* appears in the list. | ||
| Return the number of times *value* appears in the list. | ||
|
|
||
|
|
||
| .. method:: list.sort(*, key=None, reverse=False) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about this. I tried to avoid
value *value*.