[Python-ideas] New explicit methods to trim strings
pythonchb at gmail.com
Sun Mar 24 13:34:23 EDT 2019
On Sun, Mar 24, 2019 at 2:47 AM Alex Grigoryev <evrial at gmail.com> wrote:
> Yeah good idea with names because php ltrim does the same as lstrip in
> Normally I'd expect strip to behave as I proposed, not like input a string
> as mask of characters, which is more rare use case and confusing in some
I agree -- I actually wrote buggy code in a PyPi published package that
incorrectly used strip(*) in this way: i.e. I expected.
My bad for not reading the docs carefully and writing crappy tests (yes,
there were tests -- shows you how meaningless 100% coverage is)
So +1 for some version of "remove exactly this substring from the left or
right of a string" I agree that the "either end" option is unlikley to be
useful, and it the rare case you want it, you can call both.
I'll let others bikeshed on the name.
And this really is simple enough that I don't want to reach for regex's for
it. That is, I'd write it by hand rather than mess with that.
Christopher Barker, PhD
Python Language Consulting
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas