
Sorry, another niggle re handling an empty affix: With your Python implementation, 'aba'.cutprefix(('', 'a')) == 'aba' 'aba'.cutsuffix(('', 'a')) == 'ab' This seems surprising. Rob Gadfly Cliffe On 22/03/2020 23:23, Dennis Sweeney wrote:
Much appreciated! I will add that single quote and change those snippets to::
s = 'FooBar' * 100 + 'Baz' prefixes = ('Bar', 'Foo') while len(s) != len(s := s.cutprefix(prefixes)): pass s 'Baz'
and::
s = 'FooBar' * 100 + 'Baz' prefixes = ('Bar', 'Foo') while s.startswith(prefixes): s = s.cutprefix(prefixes) s 'Baz'
Python-Dev mailing list -- python-dev@python.org To unsubscribe send an email to python-dev-leave@python.org https://mail.python.org/mailman3/lists/python-dev.python.org/ Message archived at https://mail.python.org/archives/list/python-dev@python.org/message/QJ54X6WH... Code of Conduct: http://python.org/psf/codeofconduct/