String strip methods take a set of characters to strip, not a specific
string / character sequence. They remove ALL the characters in that set
from the left or right until the first character which is not in the set.
This can be simply demonstrated here:
>>> "foobar".strip("f")
'oobar'
>>> "foobar".strip("fo")
'bar'
On Thu, Jun 27, 2019 at 11:11 AM <[email protected]> wrote:
> Anyone experienced anything like this?
>
> The behavior seems consistent but unexpected.
>
> python 3.6 on both windows (10) and linux (ubuntu 18.04) seem to exhibit
> the same odd behavior.
>
> something about a docker-image looking string seems to trigger this
> behavior. The behavior seems as expected for other strings.
>
>
> Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900
> 64 bit (AMD64)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
>
>
> sample_string_1 = "namespace/something-plugin-extra:dev"
>
> print(sample_string_1.lstrip("namespace/something-plugin"))
> xtra:dev
>
> print(sample_string_1.lstrip("namespace/something-plug"))
> xtra:dev
>
> print(sample_string_1.lstrip("namespace/something-plu"))
> xtra:dev
>
> print(sample_string_1.lstrip("namespace/something-pl"))
> ugin-extra:dev
>
>
> sample_string_1 = "namespace/something-plugxx-extra:dev"
> print(sample_string_1.lstrip("namespace/something-plugin"))
> xx-extra:dev
>
> print(sample_string_1.lstrip("namespace/something-plug"))
> xx-extra:dev
>
> print(sample_string_1.lstrip("namespace/something-plu"))
> xx-extra:dev
>
> print(sample_string_1.lstrip("namespace/something-pl"))
> ugxx-extra:dev
>
>
>
> Python 3.6.5 (default, Apr 1 2018, 05:46:30)
> [GCC 7.3.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
>
>
> sample_string_1 = "namespace/something-plugin-extra:dev"
> print(sample_string_1.lstrip("namespace/something-plugin"))
> xtra:dev
> print(sample_string_1.lstrip("namespace/something-plug"))
> xtra:dev
> print(sample_string_1.lstrip("namespace/something-plu"))
> xtra:dev
> print(sample_string_1.lstrip("namespace/something-pl"))
> ugin-extra:dev
>
>
> sample_string_1 = "namespace/something-plugxx-extra:dev"
>
> print(sample_string_1.lstrip("namespace/something-plugin"))
> xx-extra:dev
>
> print(sample_string_1.lstrip("namespace/something-plug"))
> xx-extra:dev
>
> print(sample_string_1.lstrip("namespace/something-plu"))
> xx-extra:dev
>
> print(sample_string_1.lstrip("namespace/something-pl"))
> ugxx-extra:dev
> _______________________________________________
> Python-Dev mailing list -- [email protected]
> To unsubscribe send an email to [email protected]
> https://mail.python.org/mailman3/lists/python-dev.python.org/
> Message archived at
> https://mail.python.org/archives/list/[email protected]/message/ZWRGCGANHGVDPP44VQKRIYOYX7LNVDVG/
>
--
CALVIN SPEALMAN
SENIOR QUALITY ENGINEER
[email protected] M: +1.336.210.5107
[image: https://red.ht/sig] <https://red.ht/sig>
TRIED. TESTED. TRUSTED. <https://redhat.com/trusted>
_______________________________________________
Python-Dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/[email protected]/message/DKXUA4UJIZS2HDA2PBC6OTTH4W3KLOQD/