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: rstrip() is pilfering my 'p'
Type: behavior Stage: resolved
Components: Versions: Python 3.5
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ethan.furman, jerodg
Priority: normal Keywords:

Created on 2016-02-26 20:44 by jerodg, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg260908 - (view) Author: Jerod Gawne (jerodg) Date: 2016-02-26 20:44
Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32

In[4]: str = 'aaaaaaap.py'
In[5]: print(str.rstrip('.py'))
aaaaaaa

In[6]: str = 'aaaaaaap.pdf'
In[7]: print(str.rstrip('.pdf'))
aaaaaaa

In[8]: str = 'aaaaaaab.pdf'
In[9]: print(str.rstrip('.pdf'))
aaaaaaab

In[10]: str = 'apapapab.pdf'
In[11]: print(str.rstrip('.pdf'))
apapapab

In[12]: str = 'apapapap.pdf'
In[13]: print(str.rstrip('.pdf'))
apapapa

what's with the 'p' pilfering?

In[14]: str = 'apapapab.bdf'
In[15]: print(str.rstrip('.bdf'))
apapapa
In[16]: print(str.rstrip(r'.bdf'))
apapapa

In[18]: print(str.rstrip('\.bdf'))
apapapa

Actually though, it's grabbing an additional character before the '.' the same as the one after.
msg260909 - (view) Author: Ethan Furman (ethan.furman) * (Python committer) Date: 2016-02-26 20:48
https://docs.python.org/3/library/stdtypes.html#str.strip
---------------------------------------------------------
[...] The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped:
History
Date User Action Args
2022-04-11 14:58:28adminsetgithub: 70634
2016-02-26 20:50:28eryksunsetstage: resolved
2016-02-26 20:48:12ethan.furmansetstatus: open -> closed

nosy: + ethan.furman
messages: + msg260909

resolution: not a bug
2016-02-26 20:44:07jerodgcreate