Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libstring.tex @ 7863:d773db06355c legacy-trunk
Remove obsolete lines like this:
\setindexsubitem{(in module frobnitz)}
These are no longer needed when present before any other \setindexsubitem{}
in the module section. The indexsubitem is now set by \bimodindex and
\stmodindex.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Sat, 04 Apr 1998 05:56:51 +0000 |
| parents | 0cbc9df882b6 |
| children | 8e5223680a9d |
| rev | line source |
|---|---|
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 \section{Standard Module \sectcode{string}} |
| 5818 | 2 \label{module-string} |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 \stmodindex{string} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 This module defines some constants useful for checking character |
| 6872 | 6 classes and some useful string functions. See the module |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
7 \module{re}\refstmodindex{re} for string functions based on regular |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
8 expressions. |
|
2463
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
9 |
|
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
10 The constants defined in this module are are: |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
11 |
|
7277
bf4e790bd61a
Remove all \bcode / \ecode cruft; this is no longer needed. See previous
Fred Drake <fdrake@acm.org>
parents:
7185
diff
changeset
|
12 \setindexsubitem{(data in module string)} |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
13 \begin{datadesc}{digits} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 The string \code{'0123456789'}. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 \end{datadesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 \begin{datadesc}{hexdigits} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 The string \code{'0123456789abcdefABCDEF'}. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 \end{datadesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 \begin{datadesc}{letters} |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
22 The concatenation of the strings \function{lowercase()} and |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
23 \function{uppercase()} described below. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 \end{datadesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 \begin{datadesc}{lowercase} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 A string containing all the characters that are considered lowercase |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 letters. On most systems this is the string |
|
2453
cdd3a721b40e
a few typographical changes (e.g. -- => ---) and lots of new stuff in the WWW chapter
Guido van Rossum <guido@python.org>
parents:
1789
diff
changeset
|
29 \code{'abcdefghijklmnopqrstuvwxyz'}. Do not change its definition --- |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
30 the effect on the routines \function{upper()} and |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
31 \function{swapcase()} is undefined. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
32 \end{datadesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
33 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
34 \begin{datadesc}{octdigits} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
35 The string \code{'01234567'}. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
36 \end{datadesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
37 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
38 \begin{datadesc}{uppercase} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
39 A string containing all the characters that are considered uppercase |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
40 letters. On most systems this is the string |
|
2453
cdd3a721b40e
a few typographical changes (e.g. -- => ---) and lots of new stuff in the WWW chapter
Guido van Rossum <guido@python.org>
parents:
1789
diff
changeset
|
41 \code{'ABCDEFGHIJKLMNOPQRSTUVWXYZ'}. Do not change its definition --- |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
42 the effect on the routines \function{lower()} and |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
43 \function{swapcase()} is undefined. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
44 \end{datadesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
45 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 \begin{datadesc}{whitespace} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 A string containing all characters that are considered whitespace. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 On most systems this includes the characters space, tab, linefeed, |
|
2453
cdd3a721b40e
a few typographical changes (e.g. -- => ---) and lots of new stuff in the WWW chapter
Guido van Rossum <guido@python.org>
parents:
1789
diff
changeset
|
49 return, formfeed, and vertical tab. Do not change its definition --- |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
50 the effect on the routines \function{strip()} and \function{split()} |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
51 is undefined. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 \end{datadesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 |
|
2463
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
54 The functions defined in this module are: |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
55 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
56 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 \begin{funcdesc}{atof}{s} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 Convert a string to a floating point number. The string must have |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 the standard syntax for a floating point literal in Python, optionally |
|
5245
c5fd327057c6
Add cross-refs for int() to atoi() etc.
Guido van Rossum <guido@python.org>
parents:
5212
diff
changeset
|
60 preceded by a sign (\samp{+} or \samp{-}). Note that this behaves |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
61 identical to the built-in function |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
62 \function{float()}\bifuncindex{float} when passed a string. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
65 \begin{funcdesc}{atoi}{s\optional{, base}} |
|
2576
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
66 Convert string \var{s} to an integer in the given \var{base}. The |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
67 string must consist of one or more digits, optionally preceded by a |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
68 sign (\samp{+} or \samp{-}). The \var{base} defaults to 10. If it is |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
69 0, a default base is chosen depending on the leading characters of the |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
70 string (after stripping the sign): \samp{0x} or \samp{0X} means 16, |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
71 \samp{0} means 8, anything else means 10. If \var{base} is 16, a |
|
5245
c5fd327057c6
Add cross-refs for int() to atoi() etc.
Guido van Rossum <guido@python.org>
parents:
5212
diff
changeset
|
72 leading \samp{0x} or \samp{0X} is always accepted. Note that when |
|
c5fd327057c6
Add cross-refs for int() to atoi() etc.
Guido van Rossum <guido@python.org>
parents:
5212
diff
changeset
|
73 invoked without \var{base} or with \var{base} set to 10, this behaves |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
74 identical to the built-in function \function{int()} when passed a string. |
|
5245
c5fd327057c6
Add cross-refs for int() to atoi() etc.
Guido van Rossum <guido@python.org>
parents:
5212
diff
changeset
|
75 (Also note: for a more flexible interpretation of numeric literals, |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
76 use the built-in function \function{eval()}\bifuncindex{eval}.) |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
77 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
78 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
79 \begin{funcdesc}{atol}{s\optional{, base}} |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
80 Convert string \var{s} to a long integer in the given \var{base}. The |
|
2576
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
81 string must consist of one or more digits, optionally preceded by a |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
82 sign (\samp{+} or \samp{-}). The \var{base} argument has the same |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
83 meaning as for \function{atoi()}. A trailing \samp{l} or \samp{L} is |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
84 not allowed, except if the base is 0. Note that when invoked without |
|
5245
c5fd327057c6
Add cross-refs for int() to atoi() etc.
Guido van Rossum <guido@python.org>
parents:
5212
diff
changeset
|
85 \var{base} or with \var{base} set to 10, this behaves identical to the |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
86 built-in function \function{long()}\bifuncindex{long} when passed a |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
87 string. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
88 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
89 |
|
3996
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
90 \begin{funcdesc}{capitalize}{word} |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
91 Capitalize the first character of the argument. |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
92 \end{funcdesc} |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
93 |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
94 \begin{funcdesc}{capwords}{s} |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
95 Split the argument into words using \function{split()}, capitalize |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
96 each word using \function{capitalize()}, and join the capitalized |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
97 words using \function{join()}. Note that this replaces runs of |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
98 whitespace characters by a single space, and removes leading and |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
99 trailing whitespace. |
|
3996
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
100 \end{funcdesc} |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
101 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
102 \begin{funcdesc}{expandtabs}{s, tabsize} |
|
2527
815dfaa6a778
small changes by Soren Larsen
Guido van Rossum <guido@python.org>
parents:
2463
diff
changeset
|
103 Expand tabs in a string, i.e.\ replace them by one or more spaces, |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 depending on the current column and the given tab size. The column |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
105 number is reset to zero after each newline occurring in the string. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
106 This doesn't understand other non-printing characters or escape |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 sequences. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
108 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
109 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
110 \begin{funcdesc}{find}{s, sub\optional{, start\optional{,end}}} |
|
6493
bb8c3004d758
count() now has a 4th parameter too. Also rephrased the docs for find
Guido van Rossum <guido@python.org>
parents:
5818
diff
changeset
|
111 Return the lowest index in \var{s} where the substring \var{sub} is |
|
bb8c3004d758
count() now has a 4th parameter too. Also rephrased the docs for find
Guido van Rossum <guido@python.org>
parents:
5818
diff
changeset
|
112 found such that \var{sub} is wholly contained in |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
113 \code{\var{s}[\var{start}:\var{end}]}. Return \code{-1} on failure. |
|
6493
bb8c3004d758
count() now has a 4th parameter too. Also rephrased the docs for find
Guido van Rossum <guido@python.org>
parents:
5818
diff
changeset
|
114 Defaults for \var{start} and \var{end} and interpretation of negative |
|
bb8c3004d758
count() now has a 4th parameter too. Also rephrased the docs for find
Guido van Rossum <guido@python.org>
parents:
5818
diff
changeset
|
115 values is the same as for slices. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
116 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
117 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
118 \begin{funcdesc}{rfind}{s, sub\optional{, start\optional{, end}}} |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
119 Like \function{find()} but find the highest index. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
121 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
122 \begin{funcdesc}{index}{s, sub\optional{, start\optional{, end}}} |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
123 Like \function{find()} but raise \exception{ValueError} when the |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
124 substring is not found. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
125 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
126 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
127 \begin{funcdesc}{rindex}{s, sub\optional{, start\optional{, end}}} |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
128 Like \function{rfind()} but raise \exception{ValueError} when the |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
129 substring is not found. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
132 \begin{funcdesc}{count}{s, sub\optional{, start\optional{, end}}} |
|
1750
0b645726957e
libsocket.tex: send[to] returns nbytes.
Guido van Rossum <guido@python.org>
parents:
1471
diff
changeset
|
133 Return the number of (non-overlapping) occurrences of substring |
|
6493
bb8c3004d758
count() now has a 4th parameter too. Also rephrased the docs for find
Guido van Rossum <guido@python.org>
parents:
5818
diff
changeset
|
134 \var{sub} in string \code{\var{s}[\var{start}:\var{end}]}. |
|
bb8c3004d758
count() now has a 4th parameter too. Also rephrased the docs for find
Guido van Rossum <guido@python.org>
parents:
5818
diff
changeset
|
135 Defaults for \var{start} and \var{end} and interpretation of negative |
|
bb8c3004d758
count() now has a 4th parameter too. Also rephrased the docs for find
Guido van Rossum <guido@python.org>
parents:
5818
diff
changeset
|
136 values is the same as for slices. |
|
1750
0b645726957e
libsocket.tex: send[to] returns nbytes.
Guido van Rossum <guido@python.org>
parents:
1471
diff
changeset
|
137 \end{funcdesc} |
|
0b645726957e
libsocket.tex: send[to] returns nbytes.
Guido van Rossum <guido@python.org>
parents:
1471
diff
changeset
|
138 |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 \begin{funcdesc}{lower}{s} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 Convert letters to lower case. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
141 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
142 |
|
3858
8b71ea5dacc8
Added maketrans() and optional 3rd arg to translate() (chars to delete).
Guido van Rossum <guido@python.org>
parents:
3379
diff
changeset
|
143 \begin{funcdesc}{maketrans}{from, to} |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
144 Return a translation table suitable for passing to |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
145 \function{translate()} or \function{regex.compile()}, that will map |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
146 each character in \var{from} into the character at the same position |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
147 in \var{to}; \var{from} and \var{to} must have the same length. |
|
3858
8b71ea5dacc8
Added maketrans() and optional 3rd arg to translate() (chars to delete).
Guido van Rossum <guido@python.org>
parents:
3379
diff
changeset
|
148 \end{funcdesc} |
|
8b71ea5dacc8
Added maketrans() and optional 3rd arg to translate() (chars to delete).
Guido van Rossum <guido@python.org>
parents:
3379
diff
changeset
|
149 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
150 \begin{funcdesc}{split}{s\optional{, sep\optional{, maxsplit}}} |
|
3996
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
151 Return a list of the words of the string \var{s}. If the optional |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
152 second argument \var{sep} is absent or \code{None}, the words are |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
153 separated by arbitrary strings of whitespace characters (space, tab, |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
154 newline, return, formfeed). If the second argument \var{sep} is |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
155 present and not \code{None}, it specifies a string to be used as the |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
156 word separator. The returned list will then have one more items than |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
157 the number of non-overlapping occurrences of the separator in the |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
158 string. The optional third argument \var{maxsplit} defaults to 0. If |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
159 it is nonzero, at most \var{maxsplit} number of splits occur, and the |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
160 remainder of the string is returned as the final element of the list |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
161 (thus, the list will have at most \code{\var{maxsplit}+1} elements). |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
162 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
163 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
164 \begin{funcdesc}{splitfields}{s\optional{, sep\optional{, maxsplit}}} |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
165 This function behaves identically to \function{split()}. (In the |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
166 past, \function{split()} was only used with one argument, while |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
167 \function{splitfields()} was only used with two arguments.) |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
168 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
170 \begin{funcdesc}{join}{words\optional{, sep}} |
|
3996
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
171 Concatenate a list or tuple of words with intervening occurrences of |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
172 \var{sep}. The default value for \var{sep} is a single space |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
173 character. It is always true that |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
174 \samp{string.join(string.split(\var{s}, \var{sep}), \var{sep})} |
|
3996
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
175 equals \var{s}. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
176 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
178 \begin{funcdesc}{joinfields}{words\optional{, sep}} |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
179 This function behaves identical to \function{join()}. (In the past, |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
180 \function{join()} was only used with one argument, while |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
181 \function{joinfields()} was only used with two arguments.) |
|
3996
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
182 \end{funcdesc} |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
183 |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
184 \begin{funcdesc}{lstrip}{s} |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
185 Remove leading whitespace from the string \var{s}. |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
186 \end{funcdesc} |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
187 |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
188 \begin{funcdesc}{rstrip}{s} |
|
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
189 Remove trailing whitespace from the string \var{s}. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
190 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
191 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
192 \begin{funcdesc}{strip}{s} |
|
3996
0ec2ce97b8e3
Added capitalize, capwords, lstrip, rstrip, and optional 3rd argument
Guido van Rossum <guido@python.org>
parents:
3858
diff
changeset
|
193 Remove leading and trailing whitespace from the string \var{s}. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
194 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
195 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
196 \begin{funcdesc}{swapcase}{s} |
|
2527
815dfaa6a778
small changes by Soren Larsen
Guido van Rossum <guido@python.org>
parents:
2463
diff
changeset
|
197 Convert lower case letters to upper case and vice versa. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
198 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
199 |
|
3858
8b71ea5dacc8
Added maketrans() and optional 3rd arg to translate() (chars to delete).
Guido van Rossum <guido@python.org>
parents:
3379
diff
changeset
|
200 \begin{funcdesc}{translate}{s, table\optional{, deletechars}} |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
201 Delete all characters from \var{s} that are in \var{deletechars} (if |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
202 present), and then translate the characters using \var{table}, which |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
203 must be a 256-character string giving the translation for each |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
204 character value, indexed by its ordinal. |
|
3084
91c1bb75e945
added string.translate(s, table)
Guido van Rossum <guido@python.org>
parents:
2647
diff
changeset
|
205 \end{funcdesc} |
|
91c1bb75e945
added string.translate(s, table)
Guido van Rossum <guido@python.org>
parents:
2647
diff
changeset
|
206 |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
207 \begin{funcdesc}{upper}{s} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
208 Convert letters to upper case. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
209 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
210 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
211 \begin{funcdesc}{ljust}{s, width} |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
212 \funcline{rjust}{s, width} |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
213 \funcline{center}{s, width} |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
214 These functions respectively left-justify, right-justify and center a |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
215 string in a field of given width. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
216 They return a string that is at least |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
217 \var{width} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
218 characters wide, created by padding the string |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
219 \var{s} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
220 with spaces until the given width on the right, left or both sides. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
221 The string is never truncated. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
222 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
223 |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
224 \begin{funcdesc}{zfill}{s, width} |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
225 Pad a numeric string on the left with zero digits until the given |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
226 width is reached. Strings starting with a sign are handled correctly. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
227 \end{funcdesc} |
|
2463
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
228 |
|
5245
c5fd327057c6
Add cross-refs for int() to atoi() etc.
Guido van Rossum <guido@python.org>
parents:
5212
diff
changeset
|
229 \begin{funcdesc}{replace}{str, old, new\optional{, maxsplit}} |
|
5212
1f38d5fb3d23
Added docs for replace() and replace1().
Guido van Rossum <guido@python.org>
parents:
5188
diff
changeset
|
230 Return a copy of string \var{str} with all occurrences of substring |
|
5245
c5fd327057c6
Add cross-refs for int() to atoi() etc.
Guido van Rossum <guido@python.org>
parents:
5212
diff
changeset
|
231 \var{old} replaced by \var{new}. If the optional argument |
|
c5fd327057c6
Add cross-refs for int() to atoi() etc.
Guido van Rossum <guido@python.org>
parents:
5212
diff
changeset
|
232 \var{maxsplit} is given, the first \var{maxsplit} occurrences are |
|
c5fd327057c6
Add cross-refs for int() to atoi() etc.
Guido van Rossum <guido@python.org>
parents:
5212
diff
changeset
|
233 replaced. |
|
5212
1f38d5fb3d23
Added docs for replace() and replace1().
Guido van Rossum <guido@python.org>
parents:
5188
diff
changeset
|
234 \end{funcdesc} |
|
1f38d5fb3d23
Added docs for replace() and replace1().
Guido van Rossum <guido@python.org>
parents:
5188
diff
changeset
|
235 |
|
2463
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
236 This module is implemented in Python. Much of its functionality has |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
237 been reimplemented in the built-in module |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
238 \module{strop}\refbimodindex{strop}. However, you |
|
2463
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
239 should \emph{never} import the latter module directly. When |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
240 \module{string} discovers that \module{strop} exists, it transparently |
|
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
241 replaces parts of itself with the implementation from \module{strop}. |
|
2463
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
242 After initialization, there is \emph{no} overhead in using |
|
7712
0cbc9df882b6
Change "\," to just "," in function signatures. This is easier to maintain,
Fred Drake <fdrake@acm.org>
parents:
7277
diff
changeset
|
243 \module{string} instead of \module{strop}. |
