rest25/library/userdict.rst => rest262/library/userdict.rst
6   :synopsis: Class wrapper for dictionary objects.
7
8
9The module defines a mixin,  :class:`DictMixin`, defining all dictionary methods
10for classes that already have a minimum mapping interface.  This greatly
11simplifies writing classes that need to be substitutable for dictionaries (such
12as the shelve module).
13
n14-This also module defines a class, :class:`UserDict`, that acts as a wrapper
n14+This module also defines a class, :class:`UserDict`, that acts as a wrapper
15around dictionary objects.  The need for this class has been largely supplanted
16by the ability to subclass directly from :class:`dict` (a feature that became
17available starting with Python version 2.2).  Prior to the introduction of
18:class:`dict`, the :class:`UserDict` class was used to create dictionary-like
19sub-classes that obtained new behaviors by overriding existing methods or adding
20new ones.
21
22The :mod:`UserDict` module defines the :class:`UserDict` class and
63   full interface.
64
65   In addition to the four base methods, progressively more efficiency comes with
66   defining :meth:`__contains__`, :meth:`__iter__`, and :meth:`iteritems`.
67
68   Since the mixin has no knowledge of the subclass constructor, it does not define
69   :meth:`__init__` or :meth:`copy`.
70
n71+   Starting with Python version 2.6, it is recommended to use
72+   :class:`collections.MutableMapping` instead of :class:`DictMixin`.
71
72:mod:`UserList` --- Class wrapper for list objects
73==================================================
74
75.. module:: UserList
76   :synopsis: Class wrapper for list objects.
77
78
90The :mod:`UserList` module defines the :class:`UserList` class:
91
92
93.. class:: UserList([list])
94
95   Class that simulates a list.  The instance's contents are kept in a regular
96   list, which is accessible via the :attr:`data` attribute of :class:`UserList`
97   instances.  The instance's contents are initially set to a copy of *list*,
n98-   defaulting to the empty list ``[]``.  *list* can be either a regular Python
n100+   defaulting to the empty list ``[]``.  *list* can be any iterable, e.ga
99-   list, or an instance of :class:`UserList` (or a subclass).
101+   real Python list or a :class:`UserList` object.
102+ 
103+   .. note::
104+      The :class:`UserList` class has been moved to the :mod:`collections`
105+      module in Python 3.0. The :term:`2to3` tool will automatically adapt
106+      imports when converting your sources to 3.0.
107+ 
100
101In addition to supporting the methods and operations of mutable sequences (see
102section :ref:`typesseq`), :class:`UserList` instances provide the following
103attribute:
104
105
106.. attribute:: UserList.data
107
160   Class that simulates a string or a Unicode string object.  The instance's
161   content is kept in a regular string or Unicode string object, which is
162   accessible via the :attr:`data` attribute of :class:`UserString` instances.  The
163   instance's contents are initially set to a copy of *sequence*.  *sequence* can
164   be either a regular Python string or Unicode string, an instance of
165   :class:`UserString` (or a subclass) or an arbitrary sequence which can be
166   converted into a string using the built-in :func:`str` function.
167
n176+   .. note::
177+      The :class:`UserString` class has been moved to the :mod:`collections`
178+      module in Python 3.0. The :term:`2to3` tool will automatically adapt
179+      imports when converting your sources to 3.0.
180+ 
181+ 
168
169.. class:: MutableString([sequence])
170
171   This class is derived from the :class:`UserString` above and redefines strings
172   to be *mutable*.  Mutable strings can't be used as dictionary keys, because
173   dictionaries require *immutable* objects as keys.  The main intention of this
174   class is to serve as an educational example for inheritance and necessity to
175   remove (override) the :meth:`__hash__` method in order to trap attempts to use a
176   mutable object as dictionary key, which would be otherwise very error prone and
177   hard to track down.
178
n193+   .. deprecated:: 2.6
194+      The :class:`MutableString` class has been removed in Python 3.0.
195+ 
179In addition to supporting the methods and operations of string and Unicode
t180-objects (see section :ref:`string-methods`, "String Methods"),
t197+objects (see section :ref:`string-methods`):class:`UserString` instances
181-:class:`UserString` instances provide the following attribute:
198+provide the following attribute:
182
183
184.. attribute:: MutableString.data
185
186   A real Python string or Unicode object used to store the content of the
187   :class:`UserString` class.
188
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op