Hello all , I found a bug in python I'm using python 2.4 with debian etch string.lstrip("source/old_prog","source/") return "ld_prog" instead of "old_prog" So I wanted to create a patch in order to contribute to python, but I have some question : - grep 'def lstrip' show that this function are defined in string.py In this fill I read : # NOTE: Everything below here is deprecated. Use string methods instead. # This stuff will go away in Python 3.0. so lstrip is deprecated, and we are recommanded to use string method But this is string.py which define string method, isn't it ? - The function lstrip is : def lstrip(s, chars=None): """lstrip(s [,chars]) -> string Return a copy of the string s with leading whitespace removed. If chars is given and not None, remove characters in chars instead. """ return s.lstrip(chars) but where is defined this lstrip(chars) function ???? I can't found it with grep. Sorry I'm a c programer, and I'm not used with python for me, It's easier to debug c program than python :)
draconux> I found a bug in python I'm using python 2.4 with debian etch draconux> string.lstrip("source/old_prog","source/") return "ld_prog" draconux> instead of "old_prog" The above is the same as "source/old_prog".lstrip("source/") String methods are defined in the Objects/stringobject.c file of the source distribution. Skip
Am Samstag 13 Mai 2006 17:30 schrieb draconux:
I found a bug in python I'm using python 2.4 with debian etch
string.lstrip("source/old_prog","source/") return "ld_prog" instead of "old_prog"
This is not a bug, but rather expected behaviour. Read the specification of lstrip() correctly. --- Heiko.
draconux wrote:
Hello all , string.lstrip("source/old_prog","source/") return "ld_prog" instead of "old_prog"
You are misunderstanding what the second argument to lstrip does. It is interpreted as a list of characters; and lstrip will remove the maximal prefix of the string that consists of these characters. E.g.:
'aaabbbcccaax'.lstrip('abc') 'x'
The first character in your string that is not one of the characters 's', 'o', 'u', 'r', 'c', 'e', or '/' is 'l', so it strips all characters up to that one. -Edward
участники (4)
-
draconux
-
Edward Loper
-
Heiko Wundram
-
skip@pobox.com