[Python-Dev] str.lstrip bug?

Facundo Batista facundobatista at gmail.com
Tue Mar 10 18:34:26 CET 2015


On Tue, Mar 10, 2015 at 2:27 PM, lou xiao <lox.xiao at gmail.com> wrote:

> 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'

On one hand, this is the "development of python itself" list; this
issue was more aimed to the general python list, of you was sure that
this is a real bug, to the issue tracker.

On the other hand, this is not a bug! If you pass a parameter to
lstrip it will (quoted from its help) "remove characters in chars
instead.", so the moment you pass "device_", it removes all those
characers from the left... note that the 'i' is removed twice.

Regards,

-- 
.    Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
Twitter: @facundobatista


More information about the Python-Dev mailing list