Issue 29018: Misinformation when showing how slices work in The Tutorial (original) (raw)
Issue29018
Created on 2016-12-19 21:19 by issuefinder, last changed 2022-04-11 14:58 by admin. This issue is now closed.
Messages (4) | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
msg283649 - (view) | Author: (issuefinder) | Date: 2016-12-19 21:19 | |||||||||||
In this page: https://docs.python.org/3/tutorial/introduction.html#strings When showing how slices work: +---+---+---+---+---+---+ | P | y | t | h | o | n | +---+---+---+---+---+---+ 0 1 2 3 4 5 6 -6 -5 -4 -3 -2 -1 The accurate matrix is: +---+---+---+---+---+---+ | P | y | t | h | o | n | +---+---+---+---+---+---+ 0 1 2 3 4 5 6 0 -6 -5 -4 -3 -2 -1 |
msg283652 - (view) | Author: R. David Murray (r.david.murray) * ![]() |
Date: 2016-12-19 21:55 | |||||||||||
If your version was correct, 'python'[-2:] would produce 'n', which is not what it produces. Perhaps you being confused by the fact that the diagram is pointing the indexes *between* the characters? That's the point of the mnemonic and I find it very useful to think of it that way, myself. | |||||||||||||
msg283655 - (view) | Author: Steven D'Aprano (steven.daprano) * ![]() |
Date: 2016-12-19 23:37 | |||||||||||
You haven't given any reason to explain why you think the existing docs are wrong, nor any reason why you think your version is better. Just stating that the docs give "misinformation" is not good enough. By your matrix, 'Python'[0:-1] should take a slice starting from the left of 'P' and ending at the *right* of 'n', returning 'Python' unchanged. According to the original, documented matrix, 'Python'[0:-1] takes a slice starting at the left of 'P' and ending at the *left* of 'n', returning 'Pytho'. without the n, which is what actually does happen. You should also consider the slice 'Python'[-6:-5] according to the documented matrix (returns 'P') and your matrix (returns 'y'). | |||||||||||||
msg283877 - (view) | Author: (issuefinder) | Date: 2016-12-23 13:08 | |||||||||||
You seem to be right. Sorry about the incovenience. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:58:40 | admin | set | github: 73204 |
2016-12-23 13:08:33 | issuefinder | set | messages: + |
2016-12-19 23:37:31 | steven.daprano | set | status: open -> closednosy: + steven.dapranomessages: + resolution: not a bugstage: resolved |
2016-12-19 21:55:01 | r.david.murray | set | nosy: + r.david.murraymessages: + |
2016-12-19 21:19:44 | issuefinder | create |