On 2 Apr 2019, at 13:23, Paul Moore <p.f.moore@gmail.com> wrote:
It would be really helpful if someone could go through the various use cases presented in this thread and classify them - filename manipulation, natural language uses, and "other". We could then focus on the "other" category to get a better feel for what use cases might act as a good argument for the feature. To me, it's starting to feel like a proposal that looks deceptively valuable because it's a "natural", or "obvious", addition to make, and there's a weight of people thinking of cases where they "might find it useful", but the reality is that many of those cases are not actually as good a fit for the feature as it seems at first glance. It would help the people in favour of the proposal to make their case if they could dispel that impression by giving a clearer summary of the expected use cases...
I found two instances of strip_prefix in the code base I work on: stripping "origin/" from git branch names, and "Author:" to get the author from log output, again from git. A good place to look for examples is this: https://github.com/search?utf8=✓&q=%22strip_prefix%28%22+extension%3Apy+language%3APython+language%3APython&type=Code&ref=advsearch&l=Python&l=Python <https://github.com/search?utf8=%E2%9C%93&q=%22strip_prefix(%22+extension:py+language:Python+language:Python&type=Code&ref=advsearch&l=Python&l=Python> A pattern that one sees quickly is that there are lots and lots of functions that strip a specific and hardcoded prefix. There's a lot of path manipulation too. And of course, there's an enormous amount of copy paste (jsfunctions.py is everywhere!). Some examples from the search above: Removing "file:" prefix: https://github.com/merijn/dotfiles/blob/43c736c73c5eda413dc7b4615bb679bd43a1... <https://github.com/merijn/dotfiles/blob/43c736c73c5eda413dc7b4615bb679bd43a1...> This is a strange one, which seems to strip different things? https://github.com/imperodesign/paas-tools/blob/649372762a18acefed0a24a970b9... <https://github.com/imperodesign/paas-tools/blob/649372762a18acefed0a24a970b9...> Removing "master.": https://github.com/mithro/chromium-build/blob/98d83e124dc08510756906171922a2... <https://github.com/mithro/chromium-build/blob/98d83e124dc08510756906171922a2...> Also not path: https://github.com/BlissRoms-x86/platform_external_swiftshader/blob/01c0db17... <https://github.com/BlissRoms-x86/platform_external_swiftshader/blob/01c0db17...> Removing "Re:" from email subject lines: https://github.com/emersion/python-emailthreads/blob/0a56af7fd6de16105c27b7c... <https://github.com/emersion/python-emailthreads/blob/0a56af7fd6de16105c27b7c...> Removing "MAILER_": https://github.com/vitalk/flask-mailer/blob/c724643f13e51d2e57546164e3e4abf9... <https://github.com/vitalk/flask-mailer/blob/c724643f13e51d2e57546164e3e4abf9...> I'm giving up now, because I got tired :) / Anders