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.

Title: rstrip removes the trailing `e`s.
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.8
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Athul-R, BTaskaya, zach.ware
Priority: normal Keywords:

Created on 2020-11-10 15:31 by Athul-R, last changed 2022-04-11 14:59 by admin. This issue is now closed.

File name Uploaded Description Edit Athul-R, 2020-11-10 15:31 Bug potraying different cases.
Messages (3)
msg380678 - (view) Author: Athul R (Athul-R) Date: 2020-11-10 15:31
rstrip removes the trailing `e`s. 

i = "external_eeeeeeeee_object"
i = i.rstrip('_object')
It should have printed `external_eeeeeeeee` but it prints only `external_`. 

It happens only when I user rstrip("_object") not for other strings. 

# =======================================================
# it works fine in the below case. 

i = "external_eeeeeeeee_trail"
i = i.rstrip('_trail')
It should have prints `external_eeeeeeeee`
msg380681 - (view) Author: Zachary Ware (zach.ware) * (Python committer) Date: 2020-11-10 15:48

The `{l,r,}strip` methods remove all characters contained in the passed-in string; `"aabbccddeeffgg".rstrip("gfe") == "aabbccdd"`
msg380690 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-11-10 17:16
For 3.9+, you could do exactly what you want with .removesuffix (/.removeprefix) methods;
>>> test = "external_eeeeeeeee_object"
>>> test.removesuffix("_object")
Date User Action Args
2022-04-11 14:59:37adminsetgithub: 86479
2020-11-10 17:16:30BTaskayasetnosy: + BTaskaya
messages: + msg380690
2020-11-10 15:48:57zach.waresetstatus: open -> closed

nosy: + zach.ware
messages: + msg380681

resolution: not a bug
stage: resolved
2020-11-10 15:31:08Athul-Rcreate