Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accept sets or collections for str.strip/lstrip/rstrip #56653

Closed
petere mannequin opened this issue Jun 29, 2011 · 4 comments
Closed

accept sets or collections for str.strip/lstrip/rstrip #56653

petere mannequin opened this issue Jun 29, 2011 · 4 comments
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement

Comments

@petere
Copy link
Mannequin

petere mannequin commented Jun 29, 2011

BPO 12444
Nosy @rhettinger, @ezio-melotti, @merwok, @petere

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = <Date 2011-06-30.17:46:11.282>
created_at = <Date 2011-06-29.20:56:36.875>
labels = ['type-feature', 'library']
title = 'accept sets or collections for str.strip/lstrip/rstrip'
updated_at = <Date 2011-06-30.17:46:11.280>
user = 'https://github.com/petere'

bugs.python.org fields:

activity = <Date 2011-06-30.17:46:11.280>
actor = 'rhettinger'
assignee = 'none'
closed = True
closed_date = <Date 2011-06-30.17:46:11.282>
closer = 'rhettinger'
components = ['Library (Lib)']
creation = <Date 2011-06-29.20:56:36.875>
creator = 'petere'
dependencies = []
files = []
hgrepos = []
issue_num = 12444
keywords = []
message_count = 4.0
messages = ['139449', '139451', '139490', '139504']
nosy_count = 4.0
nosy_names = ['rhettinger', 'ezio.melotti', 'eric.araujo', 'petere']
pr_nums = []
priority = 'normal'
resolution = 'rejected'
stage = None
status = 'closed'
superseder = None
type = 'enhancement'
url = 'https://bugs.python.org/issue12444'
versions = []

@petere
Copy link
Mannequin Author

petere mannequin commented Jun 29, 2011

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.

@petere petere mannequin added stdlib Python modules in the Lib dir type-feature A feature request or enhancement labels Jun 29, 2011
@rhettinger
Copy link
Contributor

-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).

@merwok
Copy link
Member

merwok commented Jun 30, 2011

Agreed with Raymond. Is there some way the doc could be improved, or do we just close this report?

@rhettinger
Copy link
Contributor

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.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants