Mercurial > cpython-lru_cache-weakref
annotate Doc/lib/libuserdict.tex @ 21467:4e35fa5d5708 legacy-trunk
Add documentation for the help() built-in; contributed by Ka-Ping Yee.
This is part of SF patch #494622.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Tue, 18 Dec 2001 16:31:08 +0000 |
| parents | 5de3a5947257 |
| children | d24c8c946741 |
| rev | line source |
|---|---|
| 8918 | 1 \section{\module{UserDict} --- |
|
11081
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
2 Class wrapper for dictionary objects} |
|
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
3 |
|
8716
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7901
diff
changeset
|
4 \declaremodule{standard}{UserDict} |
|
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7901
diff
changeset
|
5 \modulesynopsis{Class wrapper for dictionary objects.} |
|
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7901
diff
changeset
|
6 |
|
20700
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
7 \note{This module is available for backward compatibility only. If |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
8 you are writing code that does not need to work with versions of |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
9 Python earlier than Python 2.2, please consider subclassing directly |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
10 from the built-in \class{dictionary} type.} |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
11 |
|
7901
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
12 This module defines a class that acts as a wrapper around |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
13 dictionary objects. It is a useful base class for |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
14 your own dictionary-like classes, which can inherit from |
|
5220
e1f613322b23
Added docs for UserDict,UserList
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 them and override existing methods or add new ones. In this way one |
|
13625
fdfd1049f36e
Rob W. W. Hooft's spelling fixes for the Library Reference. I hope
Thomas Wouters <thomas@python.org>
parents:
12220
diff
changeset
|
16 can add new behaviors to dictionaries. |
|
5220
e1f613322b23
Added docs for UserDict,UserList
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 |
| 7380 | 18 The \module{UserDict} module defines the \class{UserDict} class: |
|
5220
e1f613322b23
Added docs for UserDict,UserList
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 |
|
13625
fdfd1049f36e
Rob W. W. Hooft's spelling fixes for the Library Reference. I hope
Thomas Wouters <thomas@python.org>
parents:
12220
diff
changeset
|
20 \begin{classdesc}{UserDict}{\optional{initialdata}} |
|
15149
fdc2abdf4777
Fixed a large number of small problems, mostly noted by Detlef Lannert
Fred Drake <fdrake@acm.org>
parents:
15147
diff
changeset
|
21 Class that simulates a dictionary. The instance's |
|
5220
e1f613322b23
Added docs for UserDict,UserList
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
22 contents are kept in a regular dictionary, which is accessible via the |
|
11140
cdfa9cd4e72b
Added description of optional parameter to UserDict constructor.
Fred Drake <fdrake@acm.org>
parents:
11081
diff
changeset
|
23 \member{data} attribute of \class{UserDict} instances. If |
|
cdfa9cd4e72b
Added description of optional parameter to UserDict constructor.
Fred Drake <fdrake@acm.org>
parents:
11081
diff
changeset
|
24 \var{initialdata} is provided, \member{data} is initialized with its |
|
cdfa9cd4e72b
Added description of optional parameter to UserDict constructor.
Fred Drake <fdrake@acm.org>
parents:
11081
diff
changeset
|
25 contents; note that a reference to \var{initialdata} will not be kept, |
|
cdfa9cd4e72b
Added description of optional parameter to UserDict constructor.
Fred Drake <fdrake@acm.org>
parents:
11081
diff
changeset
|
26 allowing it be used used for other purposes. |
| 7380 | 27 \end{classdesc} |
|
5220
e1f613322b23
Added docs for UserDict,UserList
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 |
|
11081
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
29 In addition to supporting the methods and operations of mappings (see |
|
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
30 section \ref{typesmapping}), \class{UserDict} instances provide the |
|
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
31 following attribute: |
|
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
32 |
|
7901
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
33 \begin{memberdesc}{data} |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
34 A real dictionary used to store the contents of the \class{UserDict} |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
35 class. |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
36 \end{memberdesc} |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
37 |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
38 |
| 8918 | 39 \section{\module{UserList} --- |
|
11081
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
40 Class wrapper for list objects} |
|
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
41 |
|
8716
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7901
diff
changeset
|
42 \declaremodule{standard}{UserList} |
|
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7901
diff
changeset
|
43 \modulesynopsis{Class wrapper for list objects.} |
|
760dcf197048
Adjusted to use the new module synopsis support macros.
Fred Drake <fdrake@acm.org>
parents:
7901
diff
changeset
|
44 |
|
7901
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
45 |
|
20700
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
46 \note{This module is available for backward compatibility only. If |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
47 you are writing code that does not need to work with versions of |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
48 Python earlier than Python 2.2, please consider subclassing directly |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
49 from the built-in \class{list} type.} |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
50 |
|
7901
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
51 This module defines a class that acts as a wrapper around |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
52 list objects. It is a useful base class for |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
53 your own list-like classes, which can inherit from |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
54 them and override existing methods or add new ones. In this way one |
|
13625
fdfd1049f36e
Rob W. W. Hooft's spelling fixes for the Library Reference. I hope
Thomas Wouters <thomas@python.org>
parents:
12220
diff
changeset
|
55 can add new behaviors to lists. |
|
7901
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
56 |
| 7380 | 57 The \module{UserList} module defines the \class{UserList} class: |
|
5220
e1f613322b23
Added docs for UserDict,UserList
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
58 |
| 7380 | 59 \begin{classdesc}{UserList}{\optional{list}} |
|
15149
fdc2abdf4777
Fixed a large number of small problems, mostly noted by Detlef Lannert
Fred Drake <fdrake@acm.org>
parents:
15147
diff
changeset
|
60 Class that simulates a list. The instance's |
|
5220
e1f613322b23
Added docs for UserDict,UserList
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
61 contents are kept in a regular list, which is accessible via the |
| 7380 | 62 \member{data} attribute of \class{UserList} instances. The instance's |
|
7039
ab4d604822d0
Fix a typo (the word "a" was spelled "c"!).
Fred Drake <fdrake@acm.org>
parents:
5220
diff
changeset
|
63 contents are initially set to a copy of \var{list}, defaulting to the |
|
5220
e1f613322b23
Added docs for UserDict,UserList
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 empty list \code{[]}. \var{list} can be either a regular Python list, |
| 7380 | 65 or an instance of \class{UserList} (or a subclass). |
| 66 \end{classdesc} | |
|
7901
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
67 |
|
11081
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
68 In addition to supporting the methods and operations of mutable |
|
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
69 sequences (see section \ref{typesseq}), \class{UserList} instances |
|
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
70 provide the following attribute: |
|
76008f8a0e5f
Added some minor prose before the descriptions of the data attributes
Fred Drake <fdrake@acm.org>
parents:
8918
diff
changeset
|
71 |
|
7901
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
72 \begin{memberdesc}{data} |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
73 A real Python list object used to store the contents of the |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
74 \class{UserList} class. |
|
9a246d74fcb7
Separate UserDict and UserList documentation into separate sections.
Fred Drake <fdrake@acm.org>
parents:
7877
diff
changeset
|
75 \end{memberdesc} |
|
12214
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
76 |
|
15065
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
77 \strong{Subclassing requirements:} |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
78 Subclasses of \class{UserList} are expect to offer a constructor which |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
79 can be called with either no arguments or one argument. List |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
80 operations which return a new sequence attempt to create an instance |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
81 of the actual implementation class. To do so, it assumes that the |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
82 constructor can be called with a single parameter, which is a sequence |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
83 object used as a data source. |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
84 |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
85 If a derived class does not wish to comply with this requirement, all |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
86 of the special methods supported by this class will need to be |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
87 overridden; please consult the sources for information about the |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
88 methods which need to be provided in that case. |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
89 |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
90 \versionchanged[Python versions 1.5.2 and 1.6 also required that the |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
91 constructor be callable with no parameters, and offer |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
92 a mutable \member{data} attribute. Earlier versions |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
93 of Python did not attempt to create instances of the |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
94 derived class]{2.0} |
|
118ac85af30a
Add notes on the requirements for subclasses.
Fred Drake <fdrake@acm.org>
parents:
14481
diff
changeset
|
95 |
|
12214
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
96 |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
97 \section{\module{UserString} --- |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
98 Class wrapper for string objects} |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
99 |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
100 \declaremodule{standard}{UserString} |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
101 \modulesynopsis{Class wrapper for string objects.} |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
102 \moduleauthor{Peter Funk}{pf@artcom-gmbh.de} |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
103 \sectionauthor{Peter Funk}{pf@artcom-gmbh.de} |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
104 |
|
20700
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
105 \note{This \class{UserString} class from this module is available for |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
106 backward compatibility only. If you are writing code that does not |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
107 need to work with versions of Python earlier than Python 2.2, please |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
108 consider subclassing directly from the built-in \class{str} type |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
109 instead of using \class{UserString} (there is no built-in equivalent |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
110 to \class{MutableString}).} |
|
5de3a5947257
Add notes pointing out that these classes are kept for backward compatibility
Fred Drake <fdrake@acm.org>
parents:
15149
diff
changeset
|
111 |
|
15147
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
112 This module defines a class that acts as a wrapper around string |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
113 objects. It is a useful base class for your own string-like classes, |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
114 which can inherit from them and override existing methods or add new |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
115 ones. In this way one can add new behaviors to strings. |
|
12214
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
116 |
|
15147
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
117 It should be noted that these classes are highly inefficient compared |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
118 to real string or Unicode objects; this is especially the case for |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
119 \class{MutableString}. |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
120 |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
121 The \module{UserString} module defines the following classes: |
|
12214
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
122 |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
123 \begin{classdesc}{UserString}{\optional{sequence}} |
|
15149
fdc2abdf4777
Fixed a large number of small problems, mostly noted by Detlef Lannert
Fred Drake <fdrake@acm.org>
parents:
15147
diff
changeset
|
124 Class that simulates a string or a Unicode string |
|
15147
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
125 object. The instance's content is kept in a regular string or Unicode |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
126 string object, which is accessible via the \member{data} attribute of |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
127 \class{UserString} instances. The instance's contents are initially |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
128 set to a copy of \var{sequence}. \var{sequence} can be either a |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
129 regular Python string or Unicode string, an instance of |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
130 \class{UserString} (or a subclass) or an arbitrary sequence which can |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
131 be converted into a string using the built-in \function{str()} function. |
|
12214
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
132 \end{classdesc} |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
133 |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
134 \begin{classdesc}{MutableString}{\optional{sequence}} |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
135 This class is derived from the \class{UserString} above and redefines |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
136 strings to be \emph{mutable}. Mutable strings can't be used as |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
137 dictionary keys, because dictionaries require \emph{immutable} objects as |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
138 keys. The main intention of this class is to serve as an educational |
|
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
139 example for inheritance and necessity to remove (override) the |
|
15147
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
140 \method{__hash__()} method in order to trap attempts to use a |
|
12214
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
141 mutable object as dictionary key, which would be otherwise very |
|
13625
fdfd1049f36e
Rob W. W. Hooft's spelling fixes for the Library Reference. I hope
Thomas Wouters <thomas@python.org>
parents:
12220
diff
changeset
|
142 error prone and hard to track down. |
|
12214
a216fe79ae00
UserString class from Peter Funk <pf@artcom-gmbh.de>.
Fred Drake <fdrake@acm.org>
parents:
11140
diff
changeset
|
143 \end{classdesc} |
|
14481
5004349ede4d
Move description of UserString.MutableString to a location more typical
Fred Drake <fdrake@acm.org>
parents:
13625
diff
changeset
|
144 |
|
15147
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
145 In addition to supporting the methods and operations of string and |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
146 Unicode objects (see section \ref{string-methods}, ``String |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
147 Methods''), \class{UserString} instances provide the following |
|
5e5b43118c52
Note that the UserString/MutableString classes are far less efficient
Fred Drake <fdrake@acm.org>
parents:
15065
diff
changeset
|
148 attribute: |
|
14481
5004349ede4d
Move description of UserString.MutableString to a location more typical
Fred Drake <fdrake@acm.org>
parents:
13625
diff
changeset
|
149 |
|
5004349ede4d
Move description of UserString.MutableString to a location more typical
Fred Drake <fdrake@acm.org>
parents:
13625
diff
changeset
|
150 \begin{memberdesc}{data} |
|
5004349ede4d
Move description of UserString.MutableString to a location more typical
Fred Drake <fdrake@acm.org>
parents:
13625
diff
changeset
|
151 A real Python string or Unicode object used to store the content of the |
|
5004349ede4d
Move description of UserString.MutableString to a location more typical
Fred Drake <fdrake@acm.org>
parents:
13625
diff
changeset
|
152 \class{UserString} class. |
|
5004349ede4d
Move description of UserString.MutableString to a location more typical
Fred Drake <fdrake@acm.org>
parents:
13625
diff
changeset
|
153 \end{memberdesc} |
