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: lstrip remove extra characters in the presence of a matching number
Type: behavior Stage: resolved
Components: Versions: Python 3.5, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Akilesh K, christian.heimes
Priority: normal Keywords:

Created on 2019-05-31 12:40 by Akilesh K, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (2)
msg344070 - (view) Author: Akilesh K (Akilesh K) Date: 2019-05-31 12:40
When the argument to lstrip / strip has a number and it matches the string it begins to act different. 

>>> text = "apiv1appliance"
>>> text.strip("apiv1")
'liance'
>>> text.strip("apiv2")
'1appliance'
>>> text.strip("a")
'piv1appliance'
>>> text.strip("ap")
'iv1appliance'
>>> text.strip("api")
'v1appliance'
>>> text.strip("apiv")
'1appliance'
>>> text.strip("apiv1")
'liance'
>>> text.strip("apiv2")
'1appliance'
msg344072 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2019-05-31 12:43
It's not a bug. strip() does not work like you think. Please read the documentation https://docs.python.org/3/library/stdtypes.html?highlight=strip#str.strip
History
Date User Action Args
2022-04-11 14:59:16adminsetgithub: 81295
2019-05-31 12:43:05christian.heimessetstatus: open -> closed

nosy: + christian.heimes
messages: + msg344072

resolution: not a bug
stage: resolved
2019-05-31 12:40:18Akilesh Kcreate