Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libstringio.tex @ 24042:63fbbed10714 legacy-trunk
Simplify HTTPSConnection constructor.
See discussion in SF bug 458463.
| author | Jeremy Hylton <jeremy@alum.mit.edu> |
|---|---|
| date | Fri, 28 Jun 2002 23:38:14 +0000 |
| parents | 33b4357aebb8 |
| children | bd63f28ce7a8 |
| rev | line source |
|---|---|
| 8918 | 1 \section{\module{StringIO} --- |
| 10661 | 2 Read and write strings as files} |
| 3 | |
|
8730
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
4 \declaremodule{standard}{StringIO} |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
5 \modulesynopsis{Read and write strings as if they were files.} |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
6 |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
7 |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
8 This module implements a file-like class, \class{StringIO}, |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
9 that reads and writes a string buffer (also known as \emph{memory |
|
15443
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
10 files}). See the description of file objects for operations (section |
| 10661 | 11 \ref{bltin-file-objects}). |
|
8730
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
12 |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
13 \begin{classdesc}{StringIO}{\optional{buffer}} |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
14 When a \class{StringIO} object is created, it can be initialized |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
15 to an existing string by passing the string to the constructor. |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
16 If no string is given, the \class{StringIO} will start empty. |
|
15443
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
17 |
|
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
18 The \class{StringIO} object can accept either Unicode or 8-bit |
|
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
19 strings, but mixing the two may take some care. If both are used, |
|
18416
33b4357aebb8
Fix up a few style nits -- avoid "e.g." and "i.e." -- these make
Fred Drake <fdrake@acm.org>
parents:
15443
diff
changeset
|
20 8-bit strings that cannot be interpreted as 7-bit \ASCII{} (that |
|
15443
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
21 use the 8th bit) will cause a \exception{UnicodeError} to be raised |
|
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
22 when \method{getvalue()} is called. |
|
8730
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
23 \end{classdesc} |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
24 |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
25 The following methods of \class{StringIO} objects require special |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
26 mention: |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
27 |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
28 \begin{methoddesc}{getvalue}{} |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
29 Retrieve the entire contents of the ``file'' at any time before the |
|
15443
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
30 \class{StringIO} object's \method{close()} method is called. See the |
|
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
31 note above for information about mixing Unicode and 8-bit strings; |
|
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
32 such mixing can cause this method to raise \exception{UnicodeError}. |
|
8730
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
33 \end{methoddesc} |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
34 |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
35 \begin{methoddesc}{close}{} |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
36 Free the memory buffer. |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
37 \end{methoddesc} |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
38 |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
39 |
| 8918 | 40 \section{\module{cStringIO} --- |
| 10661 | 41 Faster version of \module{StringIO}} |
|
10240
359244fa6b52
Use current approach to record documentation author.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
42 |
|
8730
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
43 \declaremodule{builtin}{cStringIO} |
| 10661 | 44 \modulesynopsis{Faster version of \module{StringIO}, but not |
| 45 subclassable.} | |
| 46 \moduleauthor{Jim Fulton}{jfulton@digicool.com} | |
|
10240
359244fa6b52
Use current approach to record documentation author.
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
47 \sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org} |
|
8730
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
48 |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
49 The module \module{cStringIO} provides an interface similar to that of |
| 10661 | 50 the \refmodule{StringIO} module. Heavy use of \class{StringIO.StringIO} |
|
8730
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
51 objects can be made more efficient by using the function |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
52 \function{StringIO()} from this module instead. |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
53 |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
54 Since this module provides a factory function which returns objects of |
|
8a306dfd9f33
Move files around to get the names to match the module names except for
Fred Drake <fdrake@acm.org>
parents:
diff
changeset
|
55 built-in types, there's no way to build your own version using |
| 10661 | 56 subclassing. Use the original \refmodule{StringIO} module in that case. |
| 57 | |
|
15443
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
58 Unlike the memory files implemented by the \refmodule{StringIO} |
|
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
59 module, those provided by this module are not able to accept Unicode |
|
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
60 strings that cannot be encoded as plain \ASCII{} strings. |
|
68de9185b41e
Added information on the use of Unicode with the StringIO and cStringIO
Fred Drake <fdrake@acm.org>
parents:
10661
diff
changeset
|
61 |
| 10661 | 62 The following data objects are provided as well: |
| 63 | |
| 64 | |
| 65 \begin{datadesc}{InputType} | |
| 66 The type object of the objects created by calling | |
| 67 \function{StringIO} with a string parameter. | |
| 68 \end{datadesc} | |
| 69 | |
| 70 \begin{datadesc}{OutputType} | |
| 71 The type object of the objects returned by calling | |
| 72 \function{StringIO} with no parameters. | |
| 73 \end{datadesc} | |
| 74 | |
| 75 | |
| 76 There is a C API to the module as well; refer to the module source for | |
| 77 more information. |
