[Python-ideas] New explicit methods to trim strings

Chris Angelico rosuav at gmail.com
Mon Apr 1 21:12:40 EDT 2019


On Tue, Apr 2, 2019 at 11:53 AM Steven D'Aprano <steve at pearwood.info> wrote:
> The point I am making is not that we must not ever support multiple
> affixes, but that we shouldn't rush that decision. Let's pick the
> low-hanging fruit, and get some real-world experience with the function
> before deciding how to handle the multiple affix case.

I still haven't seen anyone actually give a good reason for not going
with "first wins", other than a paranoia that we don't have any
real-world use-cases. And there are PLENTY of real-world use-cases
where any semantics will have the same effect, and only a few where it
would be at all important (and in all of those, "first wins" has been
the correct semantic).

By saying "let's add the method, but not give it all the power yet",
you just create more version problems. "Oh, so I can use cutprefix
back as far as 3.8, but if I use more than one prefix, now I have to
say that this requires 3.9." Why not just give it the full power
straight away? Are you actually expecting to find enough use-cases
where "longest wins" or some other definition will be better?

You can debate whether it's "extremely unlikely" to matter or it's
"reasonably common" or whatever, but unless it ever matters AND has to
be something other than first-match-wins, there's no reason not to
lock in those semantics.

ChrisA


More information about the Python-ideas mailing list