@@ -15,7 +15,13 @@ \section{\module{UserDict} ---
1515them and override existing methods or add new ones. In this way one
1616can add new behaviors to dictionaries.
1717
18- The \module {UserDict} module defines the \class {UserDict} class:
18+ The module also defines a mixin defining all dictionary methods for
19+ classes that already have a minimum mapping interface. This greatly
20+ simplifies writing classes that need to be substitutable for
21+ dictionaries (such as the shelve module).
22+
23+ The \module {UserDict} module defines the \class {UserDict} class
24+ and \class {DictMixin}:
1925
2026\begin {classdesc }{UserDict}{\optional {initialdata}}
2127Class that simulates a dictionary. The instance's
@@ -35,6 +41,23 @@ \section{\module{UserDict} ---
3541class.
3642\end {memberdesc }
3743
44+ \begin {classdesc }{DictMixin}{}
45+ Mixin defining all dictionary methods for classes that already have
46+ a minimum dictionary interface including\method {__getitem__},
47+ \method {__setitem__}, \method {__delitem__}, and \method {keys}.
48+
49+ This mixin should be used as a superclass. Adding each of the
50+ above methods adds progressively more functionality. For instance,
51+ the absence of \method {__delitem__} precludes only \method {pop}
52+ and \method {popitem}.
53+
54+ While the four methods listed above are sufficient to support the
55+ entire dictionary interface, progessively more efficiency comes
56+ with defining \method {__contains__}, \method {__iter__}, and
57+ \method {iteritems}.
58+
59+ \end {classdesc }
60+
3861
3962\section {\module {UserList} ---
4063 Class wrapper for list objects }
0 commit comments