8000 bpo-39939: Add str.removeprefix and str.removesuffix by sweeneyde · Pull Request #18939 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-39939: Add str.removeprefix and str.removesuffix #18939

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

Merged
merged 39 commits into from
Apr 22, 2020
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
0addc43
Add cutprefix and cutsuffix methods to str, bytes, and bytearray.
sweeneyde Mar 10, 2020
3adb9fa
pep 7: lining up argumenets
sweeneyde Mar 11, 2020
a7a1bc8
Revert "pep 7: lining up argumenets"
sweeneyde Mar 11, 2020
fe18644
pep 7: line up arguemnts
sweeneyde Mar 11, 2020
ff8e3c6
pep 7: line up arguemnts
sweeneyde Mar 11, 2020
5339a46
📜🤖 Added by blurb_it.
blurb-it[bot] Mar 11, 2020
cc85978
add UserString methods
sweeneyde Mar 11, 2020
1442ffe
Merge branch 'cut_affix' of https://github.com/sweeneyde/cpython into…
sweeneyde Mar 11, 2020
111b0f9
update count of objects in test_doctests
sweeneyde Mar 11, 2020
8265e4d
restore clinic output
sweeneyde Mar 11, 2020
7401b87
update count of objects in test_doctests
sweeneyde Mar 11, 2020
e550171
return original when bytes.cut***fix does not find match
sweeneyde Mar 11, 2020
0a5d0a9
Document cutprefix and cutsuffix
sweeneyde Mar 12, 2020
a126438
fix doctest in docs
sweeneyde Mar 12, 2020
fbc4a50
Add credit
sweeneyde Mar 12, 2020
3783dc3
make the empty affix case fast
sweeneyde Mar 12, 2020
428e733
clarified: one affix at a time
sweeneyde Mar 12, 2020
5796757
ensure tuples are not allowed
sweeneyde Mar 12, 2020
6fe9ac5
Fix userstring type behavior
sweeneyde Mar 12, 2020
13e8296
WhatsNew and ACKS
sweeneyde Mar 12, 2020
49fa220
WhatsNew and ACKS
sweeneyde Mar 12, 2020
550beca
fix spelling
sweeneyde Mar 12, 2020 8000
01d0655
Direct readers from (l/r)strip to cut***fix
sweeneyde Mar 12, 2020
3c0e350
Merge branch 'cut_affix' of https://github.com/sweeneyde/cpython into…
sweeneyde Mar 12, 2020
fe80ba8
Fix typo in docs
sweeneyde Mar 16, 2020
ae23692
minor c formatting consistency
sweeneyde Mar 16, 2020
a9e253c
copy/paste errors; don't say 'return the original'
sweeneyde Mar 20, 2020
4c33b74
changed 'cut' to 'remove'
sweeneyde Mar 25, 2020
4413e2e
Change method names in whatsnew
sweeneyde Mar 25, 2020
5dfa968
Update Misc/NEWS.d/next/Core and Builtins/2020-03-11-19-17-36.bpo-399…
sweeneyde Mar 25, 2020
aa6eede
new names in the whatsnew header
sweeneyde Mar 28, 2020
d941711
Merge branch 'master' into cut_affix
sweeneyde Apr 9, 2020
f55836d
add examples of differences between l/rstrip and removeaffix
sweeneyde Apr 21, 2020
8d0584a
Merge branch 'cut_affix' of https://github.com/sweeneyde/cpython into…
sweeneyde Apr 21, 2020
8b6267a
apply changes from review
sweeneyde Apr 22, 2020
61cd530
apply changes from review
sweeneyde Apr 22, 2020
ffe72f1
more documentation tweaks
sweeneyde Apr 22, 2020
d8f5a99
clean up the NEWS entry
sweeneyde Apr 22, 2020
3df1f38
mention arg type in docstrings
sweeneyde Apr 22, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
clarified: one affix at a time
  • Loading branch information
sweeneyde committed Mar 12, 2020
commit 428e733ba44e34a1185c236be8b92acf08ae0829
8 changes: 8 additions & 0 deletions Doc/library/stdtypes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,8 @@ expression support in the :mod:`re` module).

The expression ``s.cutprefix(pre)`` is roughly equivalent to
``s[len(pre):] if s.startswith(pre) else s``.
Unlike :meth:`~str.startswith`, only one prefix can be passed
at a time.

.. versionadded:: 3.9

Expand All @@ -1574,6 +1576,8 @@ expression support in the :mod:`re` module).

The expression ``s.cutprefix(suf)`` is roughly equivalent to
``s[:-len(suf)] if suf and s.endswith(suf) else s``.
Unlike :meth:`~str.endswith`, only one suffix can be passed
at a time.

.. versionadded:: 3.9

Expand Down Expand Up @@ -2634,6 +2638,8 @@ arbitrary binary data.
The *prefix* may be any :term:`bytes-like object`.
The expression ``b.cutprefix(pre)`` is roughly equivalent to
``b[len(pre):] if b.startswith(pre) else b[:]``.
Unlike :meth:`~bytes.startswith`, only one prefix can be passed
at a time.

.. versionadded:: 3.9

Expand All @@ -2652,6 +2658,8 @@ arbitrary binary data.
The *suffix* may be any :term:`bytes-like object`.
The expression ``b.cutsuffix(suf)`` is roughly equivalent to
``b[:-len(suf)] if suf and b.endswith(suf) else b[:]``.
Unlike :meth:`~bytes.endswith`, 4A11 only one suffix can be passed
at a time.

.. versionadded:: 3.9

Expand Down
0