A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://mail.python.org/pipermail/python-dev/2015-March/138721.html below:

[Python-Dev] str.lstrip bug?

[Python-Dev] str.lstrip bug?Chris Angelico rosuav at gmail.com
Tue Mar 10 18:33:44 CET 2015
On Wed, Mar 11, 2015 at 4:27 AM, lou xiao <lox.xiao at gmail.com> wrote:
> I find a bug in str.lstrip, when i call str.lstrip, i get this result.
>
> tiny➜ ~ python
> Python 2.7.5+ (default, Feb 27 2014, 19:37:08)
> [GCC 4.8.1] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>>>> a='device_info'
>>>> a.lstrip('device')
> '_info'
>>>> a.lstrip('device_')
> 'nfo'
>>>>
> tiny➜ ~ uname -a
> Linux tinymint 3.11.0-12-generic #19-Ubuntu SMP Wed Oct 9 16:20:46 UTC 2013
> x86_64 x86_64 x86_64 GNU/Linux
> tiny➜ ~

It's not a bug, because it isn't doing what you think it is. It strips
a *set of characters*, not a prefix string.

https://docs.python.org/2/library/stdtypes.html#str.lstrip
https://docs.python.org/3/library/stdtypes.html#str.lstrip

ChrisA
More information about the Python-Dev mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4