classification
Title: accept sets or collections for str.strip/lstrip/rstrip
Type: enhancement Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, ezio.melotti, petere, rhettinger
Priority: normal Keywords:

Created on 2011-06-29 20:56 by petere, last changed 2011-06-30 17:46 by rhettinger. This issue is now closed.

Messages (4)
msg139449 - (view) Author: Peter Eisentraut (petere) * Date: 2011-06-29 20:56
It appears to be a pretty common mistake to think that the argument of str.strip/lstrip/rstrip is a substring rather than a set of characters.  To allow a more clearer notation, it would be nice if these functions also accepted an argument other than a string, for example a set or any collection.  Then you could write, for example:

a.strip({'a', 'b', 'c'})

I suggest to either add support for sets specifically, or more generally anything that supports the "in" operator.

I can try to code it up if it sounds acceptable.
msg139451 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-06-29 21:46
-1 on complicating the API.  The purported problem isn't pervasive enough to warrant a change (I frequently teach python classes and do code reviews and rarely encounter this issue).  Also, the proposed change isn't going to help the people who are setting out to remove a ".html" suffix and are presuming that rstrip is the way to do it.  Those folks have already made an unfounded assumption this proposal does nothing to invalidate their experiment.  AFAICT, this proposal would only benefit someone who already knows that strip characters are accepted in all combinations (as clearly documented).
msg139490 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-06-30 15:11
Agreed with Raymond.  Is there some way the doc could be improved, or do we just close this report?
msg139504 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2011-06-30 17:46
The docs are clear on this topic.  No doc change can help someone who skips reading the docs and assumes the method does something different.
History
Date User Action Args
2011-06-30 17:46:11rhettingersetstatus: open -> closed
resolution: rejected
messages: + msg139504
2011-06-30 15:11:22eric.araujosetnosy: + eric.araujo
messages: + msg139490
2011-06-29 22:14:05ezio.melottisetnosy: + ezio.melotti
2011-06-29 21:46:40rhettingersetnosy: + rhettinger
messages: + msg139451
2011-06-29 20:56:36peterecreate