This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: slice inconsistency
Type: enhancement Stage: resolved
Components: None Versions: Python 3.1
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: elazar, r.david.murray
Priority: normal Keywords:

Created on 2013-02-24 12:49 by elazar, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg182874 - (view) Author: Elazar Gershuni (elazar) * Date: 2013-02-24 12:49
slice behavior is not consistent for negative lower or upper arguments, which could be surprising:

>>> 'hello'[:-2]
'hel'
>>> 'hello'[:-1]
'hell'
>>> 'hello'[:-0]
''

this is obvious when written as literal, but not so obvious when using variables in expressions like 'fullname[:-len(lastname)]'. same goes for 'lower'.
msg182878 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-02-24 15:14
Thanks for the report, but this is working as designed, and is a fundamental part of the design of slices.

That said, I have no idea what you are referring to by saying it is inconsistent, and what is "upper" and "lower" referring to?
History
Date User Action Args
2022-04-11 14:57:42adminsetgithub: 61489
2013-02-24 15:14:36r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg182878

resolution: not a bug
stage: resolved
2013-02-24 12:49:20elazarcreate