Title: Documentation Error
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.6
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: Suraj Kumar, ammar2, docs@python, kevlevrone
Priority: normal Keywords:

Created on 2017-01-12 16:42 by Suraj Kumar, last changed 2019-05-10 11:04 by SilentGhost. This issue is now closed.

Messages (2)
msg285331 - (view) Author: Suraj Kumar (Suraj Kumar) Date: 2017-01-12 16:42

I have found one documentation mistake in section 3.1.2. Strings saying
"""Note how the start is always included, and the end always excluded. This makes sure that s[:i] + s[i:] is always equal to s:
>>>word = 'Python'
>>> word[:2] + word[2:]

I think instead of 'the end always excluded' it should be 'the end always included'.

If my observation is correct, please do the needful change.

Thanks & Regards,
msg285333 - (view) Author: Ammar Askar (ammar2) * (Python committer) Date: 2017-01-12 17:04
Given `slice[start:end]`:

What this line is trying to say is that the slice index is inclusive for the start parameter and exclusive for the end parameter.

In mathematical/interval notation this would look like [start, end)

As a quick example look at the word "Python"
Index  012345
Letter Python

If you do word[:2], the result is 'Py', notice how the t is excluded.
Date User Action Args
2019-05-10 11:04:39SilentGhostsetmessages: - msg342070
2019-05-10 11:00:10kevlevronesetnosy: + kevlevrone
messages: + msg342070
2017-01-12 17:04:49ammar2setstatus: open -> closed

nosy: + ammar2
messages: + msg285333

resolution: not a bug
stage: resolved
2017-01-12 16:42:13Suraj Kumarcreate