funnel
funnel copied to clipboard
Use `str.removeprefix` and `str.removesuffix` where relevant
trafficstars
A recurring pattern:
text: str
if text.startswith('prefix'):
text = text[len('prefix'):]
Python 3.9 has two new methods on str, removeprefix and removesuffix, that collapse these into a single line. They are safer as we usually hardcode the value of len(prefix) and linters will not catch a discrepancy.