Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 66c9f07

Browse files
committed
Note that the UserString/MutableString classes are far less efficient
than the built-in string types (suggested by Moshe Zadka <[email protected]>). Clarified what "can be converted to a string" means. Fixed a few markup nits.
1 parent ef52f60 commit 66c9f07

1 file changed

Lines changed: 22 additions & 18 deletions

File tree

Doc/lib/libuserdict.tex

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -92,23 +92,26 @@ \section{\module{UserString} ---
9292
\moduleauthor{Peter Funk}{[email protected]}
9393
\sectionauthor{Peter Funk}{[email protected]}
9494

95-
This module defines a class that acts as a wrapper around
96-
string objects. It is a useful base class for
97-
your own string-like classes, which can inherit from
98-
them and override existing methods or add new ones. In this way one
99-
can add new behaviors to strings.
95+
This module defines a class that acts as a wrapper around string
96+
objects. It is a useful base class for your own string-like classes,
97+
which can inherit from them and override existing methods or add new
98+
ones. In this way one can add new behaviors to strings.
10099

101-
The \module{UserString} module defines the \class{UserString} class:
100+
It should be noted that these classes are highly inefficient compared
101+
to real string or Unicode objects; this is especially the case for
102+
\class{MutableString}.
103+
104+
The \module{UserString} module defines the following classes:
102105

103106
\begin{classdesc}{UserString}{\optional{sequence}}
104-
Return a class instance that simulates a string or a Unicode string object.
105-
The instance's content is kept in a regular string or Unicode string
106-
object, which is accessible via the
107-
\member{data} attribute of \class{UserString} instances. The instance's
108-
contents are initially set to a copy of \var{sequence}.
109-
\var{sequence} can be either a regular Python string or Unicode string,
110-
an instance of \class{UserString} (or a subclass) or an arbitrary sequence
111-
which can be converted into a string.
107+
Return a class instance that simulates a string or a Unicode string
108+
object. The instance's content is kept in a regular string or Unicode
109+
string object, which is accessible via the \member{data} attribute of
110+
\class{UserString} instances. The instance's contents are initially
111+
set to a copy of \var{sequence}. \var{sequence} can be either a
112+
regular Python string or Unicode string, an instance of
113+
\class{UserString} (or a subclass) or an arbitrary sequence which can
114+
be converted into a string using the built-in \function{str()} function.
112115
\end{classdesc}
113116

114117
\begin{classdesc}{MutableString}{\optional{sequence}}
@@ -117,14 +120,15 @@ \section{\module{UserString} ---
117120
dictionary keys, because dictionaries require \emph{immutable} objects as
118121
keys. The main intention of this class is to serve as an educational
119122
example for inheritance and necessity to remove (override) the
120-
\function{__hash__} method in order to trap attempts to use a
123+
\method{__hash__()} method in order to trap attempts to use a
121124
mutable object as dictionary key, which would be otherwise very
122125
error prone and hard to track down.
123126
\end{classdesc}
124127

125-
In addition to supporting the methods and operations of string or
126-
Unicode objects (see section \ref{typesseq}), \class{UserString} instances
127-
provide the following attribute:
128+
In addition to supporting the methods and operations of string and
129+
Unicode objects (see section \ref{string-methods}, ``String
130+
Methods''), \class{UserString} instances provide the following
131+
attribute:
128132

129133
\begin{memberdesc}{data}
130134
A real Python string or Unicode object used to store the content of the

0 commit comments

Comments
 (0)