Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libstring.tex @ 3044:7e7bb00a0a2e legacy-trunk
Added functionality: locate CW projects, copy them, empty them and
binhex them.
| author | Jack Jansen <jack.jansen@cwi.nl> |
|---|---|
| date | Thu, 31 Aug 1995 13:47:14 +0000 |
| parents | 9b7e6d9a528d |
| children | 91c1bb75e945 |
| rev | line source |
|---|---|
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 \section{Standard Module \sectcode{string}} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 |
|
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 |
|
2463
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
6 classes and some useful string functions. See the modules |
|
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
7 \code{regex} and \code{regsub} for string functions based on regular |
|
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
8 expressions. |
|
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 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 \renewcommand{\indexsubitem}{(data in module string)} |
|
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} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 The concatenation of the strings \code{lowercase} and |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 \code{uppercase} described below. |
|
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 --- |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 the effect on the routines \code{upper} and \code{swapcase} is |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 undefined. |
|
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 --- |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
42 the effect on the routines \code{lower} and \code{swapcase} is |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
43 undefined. |
|
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 --- |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 the effect on the routines \code{strip} and \code{split} is |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 undefined. |
|
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 \renewcommand{\indexsubitem}{(in module string)} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
57 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 \begin{funcdesc}{atof}{s} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
59 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
|
60 the standard syntax for a floating point literal in Python, optionally |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 preceded by a sign (\samp{+} or \samp{-}). |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
62 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 |
|
2576
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
64 \begin{funcdesc}{atoi}{s\optional{\, base}} |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
65 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
|
66 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
|
67 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
|
68 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
|
69 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
|
70 \samp{0} means 8, anything else means 10. If \var{base} is 16, a |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
71 leading \samp{0x} or \samp{0X} is always accepted. (Note: for a more |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
72 flexible interpretation of numeric literals, use the built-in function |
|
2647
9b7e6d9a528d
typos, layout and other small things
Guido van Rossum <guido@python.org>
parents:
2576
diff
changeset
|
73 \code{eval()}.) |
|
2576
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
74 \bifuncindex{eval} |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
75 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
76 |
|
2576
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
77 \begin{funcdesc}{atol}{s\optional{\, base}} |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
78 Convert string \var{s} to a long 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
|
79 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
|
80 sign (\samp{+} or \samp{-}). The \var{base} argument has the same |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
81 meaning as for \code{atoi()}. A trailing \samp{l} or \samp{L} is not |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
82 allowed. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
83 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
84 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
85 \begin{funcdesc}{expandtabs}{s\, tabsize} |
|
2527
815dfaa6a778
small changes by Soren Larsen
Guido van Rossum <guido@python.org>
parents:
2463
diff
changeset
|
86 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
|
87 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
|
88 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
|
89 This doesn't understand other non-printing characters or escape |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
90 sequences. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
92 |
|
1767
907605320a5f
Lots of small corrections by Andrew Kuchling (plus all new rotor docs)
Guido van Rossum <guido@python.org>
parents:
1750
diff
changeset
|
93 \begin{funcdesc}{find}{s\, sub\optional{\, start}} |
|
907605320a5f
Lots of small corrections by Andrew Kuchling (plus all new rotor docs)
Guido van Rossum <guido@python.org>
parents:
1750
diff
changeset
|
94 Return the lowest index in \var{s} not smaller than \var{start} where the |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
95 substring \var{sub} is found. Return \code{-1} when \var{sub} |
|
1767
907605320a5f
Lots of small corrections by Andrew Kuchling (plus all new rotor docs)
Guido van Rossum <guido@python.org>
parents:
1750
diff
changeset
|
96 does not occur as a substring of \var{s} with index at least \var{start}. |
|
907605320a5f
Lots of small corrections by Andrew Kuchling (plus all new rotor docs)
Guido van Rossum <guido@python.org>
parents:
1750
diff
changeset
|
97 If \var{start} is omitted, it defaults to \code{0}. If \var{start} is |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 negative, \code{len(\var{s})} is added. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
99 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
100 |
|
1767
907605320a5f
Lots of small corrections by Andrew Kuchling (plus all new rotor docs)
Guido van Rossum <guido@python.org>
parents:
1750
diff
changeset
|
101 \begin{funcdesc}{rfind}{s\, sub\optional{\, start}} |
|
2527
815dfaa6a778
small changes by Soren Larsen
Guido van Rossum <guido@python.org>
parents:
2463
diff
changeset
|
102 Like \code{find} but find the highest index. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
104 |
|
1767
907605320a5f
Lots of small corrections by Andrew Kuchling (plus all new rotor docs)
Guido van Rossum <guido@python.org>
parents:
1750
diff
changeset
|
105 \begin{funcdesc}{index}{s\, sub\optional{\, start}} |
|
1789
43ae7fcd7835
* Doc/libstring.tex (section{Standard Module \sectcode{string}}):
Guido van Rossum <guido@python.org>
parents:
1767
diff
changeset
|
106 Like \code{find} but raise \code{ValueError} when the substring is |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
107 not found. |
|
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 |
|
1767
907605320a5f
Lots of small corrections by Andrew Kuchling (plus all new rotor docs)
Guido van Rossum <guido@python.org>
parents:
1750
diff
changeset
|
110 \begin{funcdesc}{rindex}{s\, sub\optional{\, start}} |
|
1789
43ae7fcd7835
* Doc/libstring.tex (section{Standard Module \sectcode{string}}):
Guido van Rossum <guido@python.org>
parents:
1767
diff
changeset
|
111 Like \code{rfind} but raise \code{ValueError} when the substring is |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
112 not found. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
113 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
114 |
|
2576
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
115 \begin{funcdesc}{count}{s\, sub\optional{\, start}} |
|
1750
0b645726957e
libsocket.tex: send[to] returns nbytes.
Guido van Rossum <guido@python.org>
parents:
1471
diff
changeset
|
116 Return the number of (non-overlapping) occurrences of substring |
|
2576
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
117 \var{sub} in string \var{s} with index at least \var{start}. |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
118 If \var{start} is omitted, it defaults to \code{0}. If \var{start} is |
|
f47bc5554418
mass changes; fix titles; add examples; correct typos; clarifications;
Guido van Rossum <guido@python.org>
parents:
2527
diff
changeset
|
119 negative, \code{len(\var{s})} is added. |
|
1750
0b645726957e
libsocket.tex: send[to] returns nbytes.
Guido van Rossum <guido@python.org>
parents:
1471
diff
changeset
|
120 \end{funcdesc} |
|
0b645726957e
libsocket.tex: send[to] returns nbytes.
Guido van Rossum <guido@python.org>
parents:
1471
diff
changeset
|
121 |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 \begin{funcdesc}{lower}{s} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
123 Convert letters to lower case. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
124 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
125 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
126 \begin{funcdesc}{split}{s} |
|
2527
815dfaa6a778
small changes by Soren Larsen
Guido van Rossum <guido@python.org>
parents:
2463
diff
changeset
|
127 Return a list of the whitespace-delimited words of the string |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 \var{s}. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
129 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
130 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
131 \begin{funcdesc}{splitfields}{s\, sep} |
|
2527
815dfaa6a778
small changes by Soren Larsen
Guido van Rossum <guido@python.org>
parents:
2463
diff
changeset
|
132 Return a list containing the fields of the string \var{s}, using |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 the string \var{sep} as a separator. The list will have one more |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
134 items than the number of non-overlapping occurrences of the |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
135 separator in the string. Thus, \code{string.splitfields(\var{s}, ' |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
136 ')} is not the same as \code{string.split(\var{s})}, as the latter |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
137 only returns non-empty words. As a special case, |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
138 \code{splitfields(\var{s}, '')} returns \code{[\var{s}]}, for any string |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
139 \var{s}. (See also \code{regsub.split()}.) |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
140 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
141 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
142 \begin{funcdesc}{join}{words} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
143 Concatenate a list or tuple of words with intervening spaces. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
145 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
146 \begin{funcdesc}{joinfields}{words\, sep} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
147 Concatenate a list or tuple of words with intervening separators. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
148 It is always true that |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
149 \code{string.joinfields(string.splitfields(\var{t}, \var{sep}), \var{sep})} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
150 equals \var{t}. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
151 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
152 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
153 \begin{funcdesc}{strip}{s} |
|
2527
815dfaa6a778
small changes by Soren Larsen
Guido van Rossum <guido@python.org>
parents:
2463
diff
changeset
|
154 Remove leading and trailing whitespace from the string |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
155 \var{s}. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
156 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
158 \begin{funcdesc}{swapcase}{s} |
|
2527
815dfaa6a778
small changes by Soren Larsen
Guido van Rossum <guido@python.org>
parents:
2463
diff
changeset
|
159 Convert lower case letters to upper case and vice versa. |
|
1471
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
160 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
161 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
162 \begin{funcdesc}{upper}{s} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
163 Convert letters to upper case. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
164 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
165 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
166 \begin{funcdesc}{ljust}{s\, width} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
167 \funcline{rjust}{s\, width} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
168 \funcline{center}{s\, width} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
169 These functions respectively left-justify, right-justify and center a |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
170 string in a field of given width. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
171 They return a string that is at least |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 \var{width} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
173 characters wide, created by padding the string |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 \var{s} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
175 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
|
176 The string is never truncated. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
177 \end{funcdesc} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
178 |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 \begin{funcdesc}{zfill}{s\, width} |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 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
|
181 width is reached. Strings starting with a sign are handled correctly. |
|
2ec96140a36b
Restructured library documentation
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
182 \end{funcdesc} |
|
2463
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
183 |
|
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
184 This module is implemented in Python. Much of its functionality has |
|
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
185 been reimplemented in the built-in module \code{strop}. However, you |
|
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
186 should \emph{never} import the latter module directly. When |
|
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
187 \code{string} discovers that \code{strop} exists, it transparently |
|
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
188 replaces parts of itself with the implementation from \code{strop}. |
|
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
189 After initialization, there is \emph{no} overhead in using |
|
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
190 \code{string} instead of \code{strop}. |
|
e764b78a704f
add warning about strop
Guido van Rossum <guido@python.org>
parents:
2453
diff
changeset
|
191 \bimodindex{strop} |
