On 03/07/2020 05:31 AM, Alex Hall wrote:
I've defined functions like this in my own utility library and I use them
all the time, so I think they're very useful and would like to seem them
built in. But I have two functions for each end:
def strip_optional_suffix(string, suffix):
...
def strip_required_suffix(string, suffix):
...
And I know that I use the required versions much more often, because
usually if the suffix isn't there that indicates a bug somewhere that I
need to know about. So I'd like to have both the optional and required
versions implemented in this proposal, and if that's too much to add then
just the required versions. But I suspect most people will be against the
idea.
Against only having the required versions, yes. However, we do have other
functions that take an extra parameter to determine whether to raise an
exception, so perhaps:
def strip_suffix(string, /, required=False):
...
--
~Ethan~
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at
https://mail.python.org/archives/list/python-ideas@python.org/message/DUZDBUWZQJND4TTVSA6BJAV7UKIDMICC/
Code of Conduct: http://python.org/psf/codeofconduct/