Bugs item #1104923, was opened at 2005-01-18 19:58 Message generated for change (Comment added) made by tim_one You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1104923&group_id=5470
Category: Python Library >Group: Not a Bug >Status: Closed >Resolution: Invalid Priority: 5 Submitted By: Rick Coupland (rcouplan) Assigned to: Nobody/Anonymous (nobody) Summary: Bug in String rstrip method Initial Comment: There appears to be a data sensitive bug in the string rstrip method as demonstrated by the following code: >>> "ecigrcal.fle".rstrip(".fle") 'ecigrca' As you can see, it is striping an extra character. ---------------------------------------------------------------------- >Comment By: Tim Peters (tim_one) Date: 2005-01-18 20:56 Message: Logged In: YES user_id=31435 Yes, dsm001 is right. The argument is treated as a _set_ of characters to be stripped, not as a literal string. This is a natural generalization of .rstrip() without any characters, which chops off all whitespace characters (no matter how many there, and no matter what order they appear in). Passing an argument just changes the set of characters it deletes. ---------------------------------------------------------------------- Comment By: DSM (dsm001) Date: 2005-01-18 20:51 Message: Logged In: YES user_id=1175690 I don't think this is a bug. The documentation for the rstrip method reads: rstrip(...) S.rstrip([chars]) -> string or unicode Return a copy of the string S with trailing whitespace removed. If chars is given and not None, remove characters in chars instead. When you pass the method ".rle", you're telling it to treat the four characters ".", "r", "l", and "e" as trailing whitespace and remove them from the right side of the string. That's why it removes the extra "l". ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1104923&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com