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: string.rstrip strips more than supposed to in some cases
Type: Stage:
Components: None Versions:
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, goodger, headgasket-
Priority: normal Keywords:

Created on 2005-05-06 19:46 by headgasket-, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg25245 - (view) Author: Francois Payette (headgasket-) Date: 2005-05-06 19:46
import string


lfile  = "test.zip.gpg"
print lfile
lfile = lfile.rstrip(".gpg")
print lfile

should result in the same thing as:


lfile  = "test.zip.gpg"
print lfile
lfile = lfile.rstrip("gpg")
lfile = lfile.rstrip(".")
print lfile

but it does not
msg25246 - (view) Author: Francois Payette (headgasket-) Date: 2005-05-06 19:46
Logged In: YES 
user_id=1273811

version 2.4.1
msg25247 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-05-06 19:53
Logged In: YES 
user_id=849994

This is not a bug. The argument to rstrip is a string that
contains the individual characters that are to be removed.
They can occur in any order and quantity at the end of the
string.
msg25248 - (view) Author: David Goodger (goodger) (Python committer) Date: 2005-05-06 21:17
Logged In: YES 
user_id=7733

Agreed, this is not a bug.  Closing bug report.
msg25249 - (view) Author: David Goodger (goodger) (Python committer) Date: 2005-05-06 21:19
Logged In: YES 
user_id=7733

BTW, one way to do what you want is:

if lfile.endswith('.gpg'): lfile = lfile(:-4)
History
Date User Action Args
2022-04-11 14:56:11adminsetgithub: 41953
2005-05-06 19:46:05headgasket-create