On Jun 27, 2019, at 15:27, Jelle Zijlstra <jelle.zijlstra@gmail.com> wrote:
El jue., 27 jun. 2019 a las 11:51, <dan@bauman.space> escribió:
excellent and extraordinarily obvious
Thanks for the pointer.
a bit unfortunate that old docs for a module that doesn't seem to exist in py3 with less clear but still correct words is still the top google result for python string strip.
https://docs.python.org/2/library/string.html#string.lstrip
string.lstrip(s[, chars])¶
Return a copy of the string with leading characters removed. If chars is omitted or None, whitespace characters are removed. If given and not None, chars must be a string; the characters in the string will be stripped from the beginning of the string this method is called on. That function actually also behaves like str.lstrip() does in Python 3:
string.lstrip('abcd', 'ba') 'cd'
I think this is just a minor documentation issue, i.e. no need to change any behavior. The issue is that, in Python 2, there are the strip string methods as in Python 3 but there are also the old deprecated string.strip functions from the string module. As Jelle points out, the py2 string function form of strip behaves like the string method versions of strip behave in both py2 and py3. At some point the documentation for the strip string methods was changed to include this: "The chars argument is not a prefix or suffix; rather, all combinations of its values are stripped." https://docs.python.org/2/library/stdtypes.html#str.strip But the docs for the 2.7 string function were not so updated. Likewise for lstrip and rstrip. So if someone were motivated to create a 2.7 doc PR to update the wording for the three string module functions, that should lessen any confusion. -- Ned Deily nad@python.org -- []