Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
5ce0a2a1
Commit
5ce0a2a1
authored
Dec 12, 2017
by
Nitish Chandra
Committed by
Victor Stinner
Dec 12, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-31942: Document optional support of start and stop attributes in Sequence.index method (#4277)
parent
2001900b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
3 deletions
+6
-3
Doc/library/stdtypes.rst
Doc/library/stdtypes.rst
+3
-3
Lib/_collections_abc.py
Lib/_collections_abc.py
+3
-0
No files found.
Doc/library/stdtypes.rst
View file @
5ce0a2a1
...
@@ -973,9 +973,9 @@ Notes:
...
@@ -973,9 +973,9 @@ Notes:
(8)
(8)
``index`` raises :exc:`ValueError` when *x* is not found in *s*.
``index`` raises :exc:`ValueError` when *x* is not found in *s*.
When supported, the additional arguments to the index method allow
Not all implementations support passing the additional arguments *i* and *j*.
efficient searching of subsections of the sequence. Passing the extra
These arguments allow efficient searching of subsections of the sequence. Passing
arguments is roughly equivalent to using ``s[i:j].index(x)``, only
the extra
arguments is roughly equivalent to using ``s[i:j].index(x)``, only
without copying any data and with the returned index being relative to
without copying any data and with the returned index being relative to
the start of the sequence rather than the start of the slice.
the start of the sequence rather than the start of the slice.
...
...
Lib/_collections_abc.py
View file @
5ce0a2a1
...
@@ -899,6 +899,9 @@ class Sequence(Reversible, Collection):
...
@@ -899,6 +899,9 @@ class Sequence(Reversible, Collection):
def
index
(
self
,
value
,
start
=
0
,
stop
=
None
):
def
index
(
self
,
value
,
start
=
0
,
stop
=
None
):
'''S.index(value, [start, [stop]]) -> integer -- return first index of value.
'''S.index(value, [start, [stop]]) -> integer -- return first index of value.
Raises ValueError if the value is not present.
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but
recommended.
'''
'''
if
start
is
not
None
and
start
<
0
:
if
start
is
not
None
and
start
<
0
:
start
=
max
(
len
(
self
)
+
start
,
0
)
start
=
max
(
len
(
self
)
+
start
,
0
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment