mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Partially implement SF feature request 444708.
Add optional arg to string methods strip(), lstrip(), rstrip(). The optional arg specifies characters to delete. Also for UserString. Still to do: - Misc/NEWS - LaTeX docs (I did the docstrings though) - Unicode methods, and Unicode support in the string methods.
This commit is contained in:
parent
9344b14828
commit
018b0eb0f5
3 changed files with 101 additions and 18 deletions
|
@ -163,6 +163,18 @@ def run_method_tests(test):
|
|||
test('rstrip', ' hello ', ' hello')
|
||||
test('strip', 'hello', 'hello')
|
||||
|
||||
# strip/lstrip/rstrip with None arg
|
||||
test('strip', ' hello ', 'hello', None)
|
||||
test('lstrip', ' hello ', 'hello ', None)
|
||||
test('rstrip', ' hello ', ' hello', None)
|
||||
test('strip', 'hello', 'hello', None)
|
||||
|
||||
# strip/lstrip/rstrip with real arg
|
||||
test('strip', 'xyzzyhelloxyzzy', 'hello', 'xyz')
|
||||
test('lstrip', 'xyzzyhelloxyzzy', 'helloxyzzy', 'xyz')
|
||||
test('rstrip', 'xyzzyhelloxyzzy', 'xyzzyhello', 'xyz')
|
||||
test('strip', 'hello', 'hello', 'xyz')
|
||||
|
||||
test('swapcase', 'HeLLo cOmpUteRs', 'hEllO CoMPuTErS')
|
||||
test('translate', 'xyzabcdef', 'xyzxyz', transtable, 'def')
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue