All of this would be well served by a 3rd party library on PyPI. Strings
already have plenty of methods (probably too many). Having `stringtools`
would be nice to import a bunch of simple functions from.
On Mon, Mar 25, 2019 at 10:45 AM Alex Grigoryev
strip_prefix and strip_suffix I think are the best names from all and work perfectly with auto completion. Common use case:
" mailto:maria@gmail.com".strip().strip_prefix("mailto:")
On Mar 25 2019, at 4:40 pm, Anders Hovmöller
wrote: Earlier, Anders wrote: I propose naming them strip_prefix() and strip_suffix() and just skip the one that does both sides since it makes no sense to me.
This is good, except I prefer subtract_prefix(a, b), truncate_suffix etc. And for the two step process prefix_subtractor(a)(b) etc.
I don't understand the logic for "subtract". That's not a thing for non-numbers.
If you don't think "strip" is good, then I suggest "remove". Or one could also consider "without" since we're talking about something that removes /if present/ (making subtract even worse! Subtract doesn't stop at zero). So "without_prefix()". _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
[image: Sent from Mailspring] _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/
-- Keeping medicines from the bloodstreams of the sick; food from the bellies of the hungry; books from the hands of the uneducated; technology from the underdeveloped; and putting advocates of freedom in prisons. Intellectual property is to the 21st century what the slave trade was to the 16th.