Commit 7bebbe76 authored by Raymond Hettinger's avatar Raymond Hettinger

SF bug #1202395: Description of string.lstrip() needs improvement

Clarify the role of the chars argument in the strip() methods.
parent 671e95b3
...@@ -699,11 +699,17 @@ For 8-bit strings, this method is locale-dependent. ...@@ -699,11 +699,17 @@ For 8-bit strings, this method is locale-dependent.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}[string]{lstrip}{\optional{chars}} \begin{methoddesc}[string]{lstrip}{\optional{chars}}
Return a copy of the string with leading characters removed. If Return a copy of the string with leading characters removed. The
\var{chars} is omitted or \code{None}, whitespace characters are \var{chars} argument is a string specifying the set of characters
removed. If given and not \code{None}, \var{chars} must be a string; to be removed. If omitted or \code{None}, the \var{chars} argument
the characters in the string will be stripped from the beginning of defaults to removing whitespace. The \var{chars} argument is not
the string this method is called on. a prefix; rather, all combinations of its values are stripped:
\begin{verbatim}
>>> ' spacious '.lstrip()
'spacious '
>>> 'www.example.com'.lstrip('cmowz.')
'example.com'
\end{verbatim}
\versionchanged[Support for the \var{chars} argument]{2.2.2} \versionchanged[Support for the \var{chars} argument]{2.2.2}
\end{methoddesc} \end{methoddesc}
...@@ -745,11 +751,17 @@ is described in detail below. ...@@ -745,11 +751,17 @@ is described in detail below.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}[string]{rstrip}{\optional{chars}} \begin{methoddesc}[string]{rstrip}{\optional{chars}}
Return a copy of the string with trailing characters removed. If Return a copy of the string with trailing characters removed. The
\var{chars} is omitted or \code{None}, whitespace characters are \var{chars} argument is a string specifying the set of characters
removed. If given and not \code{None}, \var{chars} must be a string; to be removed. If omitted or \code{None}, the \var{chars} argument
the characters in the string will be stripped from the end of the defaults to removing whitespace. The \var{chars} argument is not
string this method is called on. a suffix; rather, all combinations of its values are stripped:
\begin{verbatim}
>>> ' spacious '.rstrip()
' spacious'
>>> 'mississippi'.rstrip('ipz')
'mississ'
\end{verbatim}
\versionchanged[Support for the \var{chars} argument]{2.2.2} \versionchanged[Support for the \var{chars} argument]{2.2.2}
\end{methoddesc} \end{methoddesc}
...@@ -791,11 +803,17 @@ position. ...@@ -791,11 +803,17 @@ position.
\end{methoddesc} \end{methoddesc}
\begin{methoddesc}[string]{strip}{\optional{chars}} \begin{methoddesc}[string]{strip}{\optional{chars}}
Return a copy of the string with leading and trailing characters Return a copy of the string with the leading and trailing characters
removed. If \var{chars} is omitted or \code{None}, whitespace removed. The \var{chars} argument is a string specifying the set of
characters are removed. If given and not \code{None}, \var{chars} characters to be removed. If omitted or \code{None}, the \var{chars}
must be a string; the characters in the string will be stripped from argument defaults to removing whitespace. The \var{chars} argument is not
the both ends of the string this method is called on. a prefix or suffix; rather, all combinations of its values are stripped:
\begin{verbatim}
>>> ' spacious '.strip()
'spacious'
>>> 'www.example.com'.strip('cmowz.')
'example'
\end{verbatim}
\versionchanged[Support for the \var{chars} argument]{2.2.2} \versionchanged[Support for the \var{chars} argument]{2.2.2}
\end{methoddesc} \end{methoddesc}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment