[issue36480] .strip() unexpected output on Windows

78 report at bugs.python.org
Sat Mar 30 21:02:13 EDT 2019


78 <78alphadeviant at gmail.com> added the comment:

I have read the documentation. It didn't function near what I thought it
did. I've never heard it stripping front and back characters in tutorials.

I solely admit I was wrong in assuming its function.

On Sat, Mar 30, 2019, 3:35 PM Eric V. Smith <report at bugs.python.org> wrote:

>
> Eric V. Smith <eric at trueblade.com> added the comment:
>
> I cannot run that example on my computer.
>
> Please reduce this to a single line of code, with no imports, that calls
> .strip() and shows your problem. Ideally you will just use constants, and
> not computed strings.
>
> Something like:
>
> >>> 'magenta.zip'.strip('pizamn')
> 'genta.'
>
> And also, show that exact same line of code executed on both platforms.
>
> That said, the problem is likely in your usage of .strip(). Please re-read
> the documentation: it does not remove substrings from a given string, it
> removes any of the given characters from the beginning and end of the
> string.
>
> So, this is correct:
> >>> 'magenta.zip'.strip('pm')
> 'agenta.zi'
>
> You're probably seeing some difference due to upper or lower case
> filenames on the two platforms.
>
> ----------
>
> _______________________________________
> Python tracker <report at bugs.python.org>
> <https://bugs.python.org/issue36480>
> _______________________________________
>

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36480>
_______________________________________


More information about the Python-bugs-list mailing list