Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / devtools / v9 / html / python / lib / node111.html
CommitLineData
920dae64
AT
1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<html>
3<head>
4<link rel="STYLESHEET" href="lib.css" type='text/css' />
5<link rel="SHORTCUT ICON" href="../icons/pyfav.png" type="image/png" />
6<link rel='start' href='../index.html' title='Python Documentation Index' />
7<link rel="first" href="lib.html" title='Python Library Reference' />
8<link rel='contents' href='contents.html' title="Contents" />
9<link rel='index' href='genindex.html' title='Index' />
10<link rel='last' href='about.html' title='About this document...' />
11<link rel='help' href='about.html' title='About this document...' />
12<link rel="prev" href="node110.html" />
13<link rel="parent" href="module-string.html" />
14<link rel="next" href="module-re.html" />
15<meta name='aesop' content='information' />
16<title>4.1.4 Deprecated string functions</title>
17</head>
18<body>
19<DIV CLASS="navigation">
20<div id='top-navigation-panel' xml:id='top-navigation-panel'>
21<table align="center" width="100%" cellpadding="0" cellspacing="2">
22<tr>
23<td class='online-navigation'><a rel="prev" title="4.1.3 String functions"
24 href="node110.html"><img src='../icons/previous.png'
25 border='0' height='32' alt='Previous Page' width='32' /></A></td>
26<td class='online-navigation'><a rel="parent" title="4.1 string "
27 href="module-string.html"><img src='../icons/up.png'
28 border='0' height='32' alt='Up One Level' width='32' /></A></td>
29<td class='online-navigation'><a rel="next" title="4.2 re "
30 href="module-re.html"><img src='../icons/next.png'
31 border='0' height='32' alt='Next Page' width='32' /></A></td>
32<td align="center" width="100%">Python Library Reference</td>
33<td class='online-navigation'><a rel="contents" title="Table of Contents"
34 href="contents.html"><img src='../icons/contents.png'
35 border='0' height='32' alt='Contents' width='32' /></A></td>
36<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
37 border='0' height='32' alt='Module Index' width='32' /></a></td>
38<td class='online-navigation'><a rel="index" title="Index"
39 href="genindex.html"><img src='../icons/index.png'
40 border='0' height='32' alt='Index' width='32' /></A></td>
41</tr></table>
42<div class='online-navigation'>
43<b class="navlabel">Previous:</b>
44<a class="sectref" rel="prev" href="node110.html">4.1.3 String functions</A>
45<b class="navlabel">Up:</b>
46<a class="sectref" rel="parent" href="module-string.html">4.1 string </A>
47<b class="navlabel">Next:</b>
48<a class="sectref" rel="next" href="module-re.html">4.2 re </A>
49</div>
50<hr /></div>
51</DIV>
52<!--End of Navigation Panel-->
53
54<H2><A NAME="SECTION006140000000000000000">
554.1.4 Deprecated string functions</A>
56</H2>
57
58<P>
59The following list of functions are also defined as methods of string and
60Unicode objects; see ``String Methods'' (section
61<A href="string-methods.html#string-methods">2.3.6</A>) for more information on those. You should consider
62these functions as deprecated, although they will not be removed until Python
633.0. The functions defined in this module are:
64
65<P>
66<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
67 <td><nobr><b><tt id='l2h-836' xml:id='l2h-836' class="function">atof</tt></b>(</nobr></td>
68 <td><var>s</var>)</td></tr></table></dt>
69<dd>
70 <div class="versionnote"><b>Deprecated since release 2.0.</b>
71Use the <tt class="function">float()</tt> built-in function.</div><p></p>
72 Convert a string to a floating point number. The string must have
73 the standard syntax for a floating point literal in Python,
74 optionally preceded by a sign ("<tt class="samp">+</tt>" or "<tt class="samp">-</tt>"). Note that
75 this behaves identical to the built-in function
76 <tt class="function">float()</tt><a id='l2h-837' xml:id='l2h-837'></a> when passed a string.
77
78<P>
79<span class="note"><b class="label">Note:</b>
80When passing in a string, values for NaN<a id='l2h-838' xml:id='l2h-838'></a>
81 and Infinity<a id='l2h-839' xml:id='l2h-839'></a> may be returned, depending on the
82 underlying C library. The specific set of strings accepted which
83 cause these values to be returned depends entirely on the C library
84 and is known to vary.</span>
85</dl>
86
87<P>
88<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
89 <td><nobr><b><tt id='l2h-840' xml:id='l2h-840' class="function">atoi</tt></b>(</nobr></td>
90 <td><var>s</var><big>[</big><var>, base</var><big>]</big><var></var>)</td></tr></table></dt>
91<dd>
92 <div class="versionnote"><b>Deprecated since release 2.0.</b>
93Use the <tt class="function">int()</tt> built-in function.</div><p></p>
94 Convert string <var>s</var> to an integer in the given <var>base</var>. The
95 string must consist of one or more digits, optionally preceded by a
96 sign ("<tt class="samp">+</tt>" or "<tt class="samp">-</tt>"). The <var>base</var> defaults to 10. If it
97 is 0, a default base is chosen depending on the leading characters
98 of the string (after stripping the sign): "<tt class="samp">0x</tt>" or "<tt class="samp">0X</tt>" means 16, "<tt class="samp">0</tt>" means 8, anything else means 10. If <var>base</var>
99 is 16, a leading "<tt class="samp">0x</tt>" or "<tt class="samp">0X</tt>" is always accepted, though
100 not required. This behaves identically to the built-in function
101 <tt class="function">int()</tt> when passed a string. (Also note: for a more
102 flexible interpretation of numeric literals, use the built-in
103 function <tt class="function">eval()</tt><a id='l2h-841' xml:id='l2h-841'></a>.)
104</dl>
105
106<P>
107<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
108 <td><nobr><b><tt id='l2h-842' xml:id='l2h-842' class="function">atol</tt></b>(</nobr></td>
109 <td><var>s</var><big>[</big><var>, base</var><big>]</big><var></var>)</td></tr></table></dt>
110<dd>
111 <div class="versionnote"><b>Deprecated since release 2.0.</b>
112Use the <tt class="function">long()</tt> built-in function.</div><p></p>
113 Convert string <var>s</var> to a long integer in the given <var>base</var>.
114 The string must consist of one or more digits, optionally preceded
115 by a sign ("<tt class="samp">+</tt>" or "<tt class="samp">-</tt>"). The <var>base</var> argument has the
116 same meaning as for <tt class="function">atoi()</tt>. A trailing "<tt class="samp">l</tt>" or
117 "<tt class="samp">L</tt>" is not allowed, except if the base is 0. Note that when
118 invoked without <var>base</var> or with <var>base</var> set to 10, this
119 behaves identical to the built-in function
120 <tt class="function">long()</tt><a id='l2h-843' xml:id='l2h-843'></a> when passed a string.
121</dl>
122
123<P>
124<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
125 <td><nobr><b><tt id='l2h-844' xml:id='l2h-844' class="function">capitalize</tt></b>(</nobr></td>
126 <td><var>word</var>)</td></tr></table></dt>
127<dd>
128 Return a copy of <var>word</var> with only its first character capitalized.
129</dl>
130
131<P>
132<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
133 <td><nobr><b><tt id='l2h-845' xml:id='l2h-845' class="function">expandtabs</tt></b>(</nobr></td>
134 <td><var>s</var><big>[</big><var>, tabsize</var><big>]</big><var></var>)</td></tr></table></dt>
135<dd>
136 Expand tabs in a string replacing them by one or more spaces,
137 depending on the current column and the given tab size. The column
138 number is reset to zero after each newline occurring in the string.
139 This doesn't understand other non-printing characters or escape
140 sequences. The tab size defaults to 8.
141</dl>
142
143<P>
144<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
145 <td><nobr><b><tt id='l2h-846' xml:id='l2h-846' class="function">find</tt></b>(</nobr></td>
146 <td><var>s, sub</var><big>[</big><var>, start</var><big>[</big><var>,end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
147<dd>
148 Return the lowest index in <var>s</var> where the substring <var>sub</var> is
149 found such that <var>sub</var> is wholly contained in
150 <code><var>s</var>[<var>start</var>:<var>end</var>]</code>. Return <code>-1</code> on failure.
151 Defaults for <var>start</var> and <var>end</var> and interpretation of
152 negative values is the same as for slices.
153</dl>
154
155<P>
156<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
157 <td><nobr><b><tt id='l2h-847' xml:id='l2h-847' class="function">rfind</tt></b>(</nobr></td>
158 <td><var>s, sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
159<dd>
160 Like <tt class="function">find()</tt> but find the highest index.
161</dl>
162
163<P>
164<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
165 <td><nobr><b><tt id='l2h-848' xml:id='l2h-848' class="function">index</tt></b>(</nobr></td>
166 <td><var>s, sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
167<dd>
168 Like <tt class="function">find()</tt> but raise <tt class="exception">ValueError</tt> when the
169 substring is not found.
170</dl>
171
172<P>
173<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
174 <td><nobr><b><tt id='l2h-849' xml:id='l2h-849' class="function">rindex</tt></b>(</nobr></td>
175 <td><var>s, sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
176<dd>
177 Like <tt class="function">rfind()</tt> but raise <tt class="exception">ValueError</tt> when the
178 substring is not found.
179</dl>
180
181<P>
182<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
183 <td><nobr><b><tt id='l2h-850' xml:id='l2h-850' class="function">count</tt></b>(</nobr></td>
184 <td><var>s, sub</var><big>[</big><var>, start</var><big>[</big><var>, end</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
185<dd>
186 Return the number of (non-overlapping) occurrences of substring
187 <var>sub</var> in string <code><var>s</var>[<var>start</var>:<var>end</var>]</code>.
188 Defaults for <var>start</var> and <var>end</var> and interpretation of
189 negative values are the same as for slices.
190</dl>
191
192<P>
193<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
194 <td><nobr><b><tt id='l2h-851' xml:id='l2h-851' class="function">lower</tt></b>(</nobr></td>
195 <td><var>s</var>)</td></tr></table></dt>
196<dd>
197 Return a copy of <var>s</var>, but with upper case letters converted to
198 lower case.
199</dl>
200
201<P>
202<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
203 <td><nobr><b><tt id='l2h-852' xml:id='l2h-852' class="function">split</tt></b>(</nobr></td>
204 <td><var>s</var><big>[</big><var>, sep</var><big>[</big><var>, maxsplit</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
205<dd>
206 Return a list of the words of the string <var>s</var>. If the optional
207 second argument <var>sep</var> is absent or <code>None</code>, the words are
208 separated by arbitrary strings of whitespace characters (space, tab,
209 newline, return, formfeed). If the second argument <var>sep</var> is
210 present and not <code>None</code>, it specifies a string to be used as the
211 word separator. The returned list will then have one more item
212 than the number of non-overlapping occurrences of the separator in
213 the string. The optional third argument <var>maxsplit</var> defaults to
214 0. If it is nonzero, at most <var>maxsplit</var> number of splits occur,
215 and the remainder of the string is returned as the final element of
216 the list (thus, the list will have at most <code><var>maxsplit</var>+1</code>
217 elements).
218
219<P>
220The behavior of split on an empty string depends on the value of <var>sep</var>.
221 If <var>sep</var> is not specified, or specified as <code>None</code>, the result will
222 be an empty list. If <var>sep</var> is specified as any string, the result will
223 be a list containing one element which is an empty string.
224</dl>
225
226<P>
227<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
228 <td><nobr><b><tt id='l2h-853' xml:id='l2h-853' class="function">rsplit</tt></b>(</nobr></td>
229 <td><var>s</var><big>[</big><var>, sep</var><big>[</big><var>, maxsplit</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
230<dd>
231 Return a list of the words of the string <var>s</var>, scanning <var>s</var>
232 from the end. To all intents and purposes, the resulting list of
233 words is the same as returned by <tt class="function">split()</tt>, except when the
234 optional third argument <var>maxsplit</var> is explicitly specified and
235 nonzero. When <var>maxsplit</var> is nonzero, at most <var>maxsplit</var>
236 number of splits - the <em>rightmost</em> ones - occur, and the remainder
237 of the string is returned as the first element of the list (thus, the
238 list will have at most <code><var>maxsplit</var>+1</code> elements).
239
240<span class="versionnote">New in version 2.4.</span>
241
242</dl>
243
244<P>
245<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
246 <td><nobr><b><tt id='l2h-854' xml:id='l2h-854' class="function">splitfields</tt></b>(</nobr></td>
247 <td><var>s</var><big>[</big><var>, sep</var><big>[</big><var>, maxsplit</var><big>]</big><var></var><big>]</big><var></var>)</td></tr></table></dt>
248<dd>
249 This function behaves identically to <tt class="function">split()</tt>. (In the
250 past, <tt class="function">split()</tt> was only used with one argument, while
251 <tt class="function">splitfields()</tt> was only used with two arguments.)
252</dl>
253
254<P>
255<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
256 <td><nobr><b><tt id='l2h-855' xml:id='l2h-855' class="function">join</tt></b>(</nobr></td>
257 <td><var>words</var><big>[</big><var>, sep</var><big>]</big><var></var>)</td></tr></table></dt>
258<dd>
259 Concatenate a list or tuple of words with intervening occurrences of
260 <var>sep</var>. The default value for <var>sep</var> is a single space
261 character. It is always true that
262 "<tt class="samp">string.join(string.split(<var>s</var>, <var>sep</var>), <var>sep</var>)</tt>" equals <var>s</var>.
263</dl>
264
265<P>
266<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
267 <td><nobr><b><tt id='l2h-856' xml:id='l2h-856' class="function">joinfields</tt></b>(</nobr></td>
268 <td><var>words</var><big>[</big><var>, sep</var><big>]</big><var></var>)</td></tr></table></dt>
269<dd>
270 This function behaves identically to <tt class="function">join()</tt>. (In the past,
271 <tt class="function">join()</tt> was only used with one argument, while
272 <tt class="function">joinfields()</tt> was only used with two arguments.)
273 Note that there is no <tt class="method">joinfields()</tt> method on string
274 objects; use the <tt class="method">join()</tt> method instead.
275</dl>
276
277<P>
278<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
279 <td><nobr><b><tt id='l2h-857' xml:id='l2h-857' class="function">lstrip</tt></b>(</nobr></td>
280 <td><var>s</var><big>[</big><var>, chars</var><big>]</big><var></var>)</td></tr></table></dt>
281<dd>
282Return a copy of the string with leading characters removed. If
283<var>chars</var> is omitted or <code>None</code>, whitespace characters are
284removed. If given and not <code>None</code>, <var>chars</var> must be a string;
285the characters in the string will be stripped from the beginning of
286the string this method is called on.
287
288<span class="versionnote">Changed in version 2.2.3:
289The <var>chars</var> parameter was added. The <var>chars</var>
290parameter cannot be passed in earlier 2.2 versions.</span>
291
292</dl>
293
294<P>
295<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
296 <td><nobr><b><tt id='l2h-858' xml:id='l2h-858' class="function">rstrip</tt></b>(</nobr></td>
297 <td><var>s</var><big>[</big><var>, chars</var><big>]</big><var></var>)</td></tr></table></dt>
298<dd>
299Return a copy of the string with trailing characters removed. If
300<var>chars</var> is omitted or <code>None</code>, whitespace characters are
301removed. If given and not <code>None</code>, <var>chars</var> must be a string;
302the characters in the string will be stripped from the end of the
303string this method is called on.
304
305<span class="versionnote">Changed in version 2.2.3:
306The <var>chars</var> parameter was added. The <var>chars</var>
307parameter cannot be passed in earlier 2.2 versions.</span>
308
309</dl>
310
311<P>
312<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
313 <td><nobr><b><tt id='l2h-859' xml:id='l2h-859' class="function">strip</tt></b>(</nobr></td>
314 <td><var>s</var><big>[</big><var>, chars</var><big>]</big><var></var>)</td></tr></table></dt>
315<dd>
316Return a copy of the string with leading and trailing characters
317removed. If <var>chars</var> is omitted or <code>None</code>, whitespace
318characters are removed. If given and not <code>None</code>, <var>chars</var>
319must be a string; the characters in the string will be stripped from
320the both ends of the string this method is called on.
321
322<span class="versionnote">Changed in version 2.2.3:
323The <var>chars</var> parameter was added. The <var>chars</var>
324parameter cannot be passed in earlier 2.2 versions.</span>
325
326</dl>
327
328<P>
329<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
330 <td><nobr><b><tt id='l2h-860' xml:id='l2h-860' class="function">swapcase</tt></b>(</nobr></td>
331 <td><var>s</var>)</td></tr></table></dt>
332<dd>
333 Return a copy of <var>s</var>, but with lower case letters
334 converted to upper case and vice versa.
335</dl>
336
337<P>
338<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
339 <td><nobr><b><tt id='l2h-861' xml:id='l2h-861' class="function">translate</tt></b>(</nobr></td>
340 <td><var>s, table</var><big>[</big><var>, deletechars</var><big>]</big><var></var>)</td></tr></table></dt>
341<dd>
342 Delete all characters from <var>s</var> that are in <var>deletechars</var> (if
343 present), and then translate the characters using <var>table</var>, which
344 must be a 256-character string giving the translation for each
345 character value, indexed by its ordinal.
346</dl>
347
348<P>
349<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
350 <td><nobr><b><tt id='l2h-862' xml:id='l2h-862' class="function">upper</tt></b>(</nobr></td>
351 <td><var>s</var>)</td></tr></table></dt>
352<dd>
353 Return a copy of <var>s</var>, but with lower case letters converted to
354 upper case.
355</dl>
356
357<P>
358<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
359 <td><nobr><b><tt id='l2h-863' xml:id='l2h-863' class="function">ljust</tt></b>(</nobr></td>
360 <td><var>s, width</var>)</td></tr></table></dt>
361<dd>
362<dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
363 <td><nobr><b><tt class="function">rjust</tt></b>(</nobr></td>
364 <td><var>s, width</var>)</td></tr></table></dt>
365<dd><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
366 <td><nobr><b><tt class="function">center</tt></b>(</nobr></td>
367 <td><var>s, width</var>)</td></tr></table></dt>
368<dd> These functions respectively left-justify, right-justify and center
369 a string in a field of given width. They return a string that is at
370 least <var>width</var> characters wide, created by padding the string
371 <var>s</var> with spaces until the given width on the right, left or both
372 sides. The string is never truncated.
373</dl>
374
375<P>
376<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
377 <td><nobr><b><tt id='l2h-866' xml:id='l2h-866' class="function">zfill</tt></b>(</nobr></td>
378 <td><var>s, width</var>)</td></tr></table></dt>
379<dd>
380 Pad a numeric string on the left with zero digits until the given
381 width is reached. Strings starting with a sign are handled
382 correctly.
383</dl>
384
385<P>
386<dl><dt><table cellpadding="0" cellspacing="0"><tr valign="baseline">
387 <td><nobr><b><tt id='l2h-867' xml:id='l2h-867' class="function">replace</tt></b>(</nobr></td>
388 <td><var>str, old, new</var><big>[</big><var>, maxreplace</var><big>]</big><var></var>)</td></tr></table></dt>
389<dd>
390 Return a copy of string <var>str</var> with all occurrences of substring
391 <var>old</var> replaced by <var>new</var>. If the optional argument
392 <var>maxreplace</var> is given, the first <var>maxreplace</var> occurrences are
393 replaced.
394</dl>
395
396<DIV CLASS="navigation">
397<div class='online-navigation'>
398<p></p><hr />
399<table align="center" width="100%" cellpadding="0" cellspacing="2">
400<tr>
401<td class='online-navigation'><a rel="prev" title="4.1.3 String functions"
402 href="node110.html"><img src='../icons/previous.png'
403 border='0' height='32' alt='Previous Page' width='32' /></A></td>
404<td class='online-navigation'><a rel="parent" title="4.1 string "
405 href="module-string.html"><img src='../icons/up.png'
406 border='0' height='32' alt='Up One Level' width='32' /></A></td>
407<td class='online-navigation'><a rel="next" title="4.2 re "
408 href="module-re.html"><img src='../icons/next.png'
409 border='0' height='32' alt='Next Page' width='32' /></A></td>
410<td align="center" width="100%">Python Library Reference</td>
411<td class='online-navigation'><a rel="contents" title="Table of Contents"
412 href="contents.html"><img src='../icons/contents.png'
413 border='0' height='32' alt='Contents' width='32' /></A></td>
414<td class='online-navigation'><a href="modindex.html" title="Module Index"><img src='../icons/modules.png'
415 border='0' height='32' alt='Module Index' width='32' /></a></td>
416<td class='online-navigation'><a rel="index" title="Index"
417 href="genindex.html"><img src='../icons/index.png'
418 border='0' height='32' alt='Index' width='32' /></A></td>
419</tr></table>
420<div class='online-navigation'>
421<b class="navlabel">Previous:</b>
422<a class="sectref" rel="prev" href="node110.html">4.1.3 String functions</A>
423<b class="navlabel">Up:</b>
424<a class="sectref" rel="parent" href="module-string.html">4.1 string </A>
425<b class="navlabel">Next:</b>
426<a class="sectref" rel="next" href="module-re.html">4.2 re </A>
427</div>
428</div>
429<hr />
430<span class="release-info">Release 2.4.2, documentation updated on 28 September 2005.</span>
431</DIV>
432<!--End of Navigation Panel-->
433<ADDRESS>
434See <i><a href="about.html">About this document...</a></i> for information on suggesting changes.
435</ADDRESS>
436</BODY>
437</HTML>