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

str.strip() and " behaviour expected? #50299

Closed
sholvar mannequin opened this issue May 17, 2009 · 2 comments
Closed

str.strip() and " behaviour expected? #50299

sholvar mannequin opened this issue May 17, 2009 · 2 comments
Labels
OS-mac stdlib Python modules in the Lib dir

Comments

@sholvar
Copy link
Mannequin

sholvar mannequin commented May 17, 2009

BPO 6049
Nosy @ezio-melotti

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 2009-05-17.19:15:46.001>
created_at = <Date 2009-05-17.18:48:54.658>
labels = ['OS-mac', 'invalid', 'library']
title = 'str.strip() and " behaviour expected?'
updated_at = <Date 2009-05-17.19:15:46.000>
user = 'https://bugs.python.org/sholvar'

bugs.python.org fields:

activity = <Date 2009-05-17.19:15:46.000>
actor = 'loewis'
assignee = 'none'
closed = True
closed_date = <Date 2009-05-17.19:15:46.001>
closer = 'loewis'
components = ['Library (Lib)', 'macOS']
creation = <Date 2009-05-17.18:48:54.658>
creator = 'sholvar'
dependencies = []
files = []
hgrepos = []
issue_num = 6049
keywords = []
message_count = 2.0
messages = ['87999', '88000']
nosy_count = 2.0
nosy_names = ['ezio.melotti', 'sholvar']
pr_nums = []
priority = 'normal'
resolution = 'not a bug'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue6049'
versions = ['Python 3.0']

@sholvar
Copy link
Mannequin Author

sholvar mannequin commented May 17, 2009

Hey guys,

is the following behaviour expected? I don't really think so...

$ python
Python 3.0.1 (r301:69597, Feb 14 2009, 19:03:52) 
[GCC 4.0.1 (Apple Inc. build 5490)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 
>>> 
>>> 
>>> 
>>> s = ' "Peter"'
>>> s
' "Peter"'
>>> s.strip()
'"Peter"'
>>> s.strip('"')
' "Peter'
>>> s.strip('\"')
' "Peter'
>>> s.strip('\"\"')
' "Peter'
>>> 
>>> 
>>> 
>>> s.strip()
'"Peter"'
>>> s.strip().strip('"')
'Peter'
>>> s.strip('"').strip()
'"Peter'

@sholvar sholvar mannequin added stdlib Python modules in the Lib dir OS-mac labels May 17, 2009
@ezio-melotti
Copy link
Member

Yes, it is expected.
When you call .strip() without args it strips the whitespaces, when you
call with an arg it strips only what you specified.
In this example:
>>> s.strip('"')
' "Peter'
the left " is not removed because there's a space in between, in this
example:
>>> s.strip().strip('"')
'Peter'
you first remove the space and then the two ".

@loewis loewis mannequin closed this as completed May 17, 2009
@loewis loewis mannequin added the invalid label May 17, 2009
@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
OS-mac stdlib Python modules in the Lib dir
Projects
None yet
Development

No branches or pull requests

1 participant