diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-01-28 21:53:10 +0100 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2024-02-18 11:32:53 +0100 |
commit | 7ab59b24a43b1219aac5caba59188934bdf69e09 (patch) | |
tree | b0ca59ccea032f7d714e174788ce39cd84e1a90f /slack/python_compatibility.py | |
parent | 584a580243c4bb246b15e07928a6561047de9e9b (diff) | |
download | wee-slack-7ab59b24a43b1219aac5caba59188934bdf69e09.tar.gz |
Fix compatibility with Python 3.8
Diffstat (limited to 'slack/python_compatibility.py')
-rw-r--r-- | slack/python_compatibility.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/slack/python_compatibility.py b/slack/python_compatibility.py new file mode 100644 index 0000000..1590894 --- /dev/null +++ b/slack/python_compatibility.py @@ -0,0 +1,14 @@ +# Copied from https://peps.python.org/pep-0616/ for support for Python < 3.9 +def removeprefix(self: str, prefix: str) -> str: + if self.startswith(prefix): + return self[len(prefix) :] + else: + return self[:] + + +# Copied from https://peps.python.org/pep-0616/ for support for Python < 3.9 +def removesuffix(self: str, suffix: str) -> str: + if suffix and self.endswith(suffix): + return self[: -len(suffix)] + else: + return self[:] |