diff options
author | Guido van Rossum <guido@python.org> | 1995-03-17 16:07:09 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-03-17 16:07:09 (GMT) |
commit | 470be14c8aa23a35a1f4d1f1260a66a85d3f3cd9 (patch) | |
tree | 4fd0b8eda81e63366598e55362ceac85adafccb4 /Doc/libstring.tex | |
parent | 7760cdea81166b7741561043c58dae171811fb2f (diff) | |
download | cpython-470be14c8aa23a35a1f4d1f1260a66a85d3f3cd9.zip cpython-470be14c8aa23a35a1f4d1f1260a66a85d3f3cd9.tar.gz cpython-470be14c8aa23a35a1f4d1f1260a66a85d3f3cd9.tar.bz2 |
mass changes; fix titles; add examples; correct typos; clarifications;
unified style; etc.
Diffstat (limited to 'Doc/libstring.tex')
-rw-r--r-- | Doc/libstring.tex | 34 |
1 files changed, 23 insertions, 11 deletions
diff --git a/Doc/libstring.tex b/Doc/libstring.tex index 0c9ad7d..960e94b 100644 --- a/Doc/libstring.tex +++ b/Doc/libstring.tex @@ -61,14 +61,25 @@ the standard syntax for a floating point literal in Python, optionally preceded by a sign (\samp{+} or \samp{-}). \end{funcdesc} -\begin{funcdesc}{atoi}{s} -Convert a string to an integer. The string must consist of one or more -digits, optionally preceded by a sign (\samp{+} or \samp{-}). -\end{funcdesc} - -\begin{funcdesc}{atol}{s} -Convert a string to a long integer. The string must consist of one -or more digits, optionally preceded by a sign (\samp{+} or \samp{-}). +\begin{funcdesc}{atoi}{s\optional{\, base}} +Convert string \var{s} to an integer in the given \var{base}. The +string must consist of one or more digits, optionally preceded by a +sign (\samp{+} or \samp{-}). The \var{base} defaults to 10. If it is +0, a default base is chosen depending on the leading characters of the +string (after stripping the sign): \samp{0x} or \samp{0X} means 16, +\samp{0} means 8, anything else means 10. If \var{base} is 16, a +leading \samp{0x} or \samp{0X} is always accepted. (Note: for a more +flexible interpretation of numeric literals, use the built-in function +\code{eval()}. +\bifuncindex{eval} +\end{funcdesc} + +\begin{funcdesc}{atol}{s\optional{\, base}} +Convert string \var{s} to a long integer in the given \var{base}. The +string must consist of one or more digits, optionally preceded by a +sign (\samp{+} or \samp{-}). The \var{base} argument has the same +meaning as for \code{atoi()}. A trailing \samp{l} or \samp{L} is not +allowed. \end{funcdesc} \begin{funcdesc}{expandtabs}{s\, tabsize} @@ -101,10 +112,11 @@ Like \code{rfind} but raise \code{ValueError} when the substring is not found. \end{funcdesc} -\begin{funcdesc}{count}{s\, sub\optional{\, i}} +\begin{funcdesc}{count}{s\, sub\optional{\, start}} Return the number of (non-overlapping) occurrences of substring -\var{sub} in string \var{s} with index at least \var{i}. -If \var{i} is omitted, it defaults to \code{0}. +\var{sub} in string \var{s} with index at least \var{start}. +If \var{start} is omitted, it defaults to \code{0}. If \var{start} is +negative, \code{len(\var{s})} is added. \end{funcdesc} \begin{funcdesc}{lower}{s} |