Guido van Rossum | 7f3b042 | 1997-03-27 14:56:18 +0000 | [diff] [blame] | 1 | \section{Standard Modules \sectcode{UserDict} and \sectcode{UserList}} |
| 2 | Each of these modules defines a class that acts as a wrapper around |
| 3 | either dictionary or list objects. They're useful base classes for |
| 4 | your own dictionary-like or list-like classes, which can inherit from |
| 5 | them and override existing methods or add new ones. In this way one |
| 6 | can add new behaviours to dictionaries or lists. |
| 7 | |
| 8 | \renewcommand{\indexsubitem}{(in module UserDict)} |
| 9 | The \code{UserDict} module defines the \code{UserDict} class: |
| 10 | |
| 11 | \begin{funcdesc}{UserDict}{} |
| 12 | Return a class instance that simulates a dictionary. The instance's |
| 13 | contents are kept in a regular dictionary, which is accessible via the |
| 14 | \code{data} attribute of \code{UserDict} instances. |
| 15 | \end{funcdesc} |
| 16 | |
| 17 | \renewcommand{\indexsubitem}{(in module UserList)} |
| 18 | The \code{UserList} module defines the \code{UserList} class: |
| 19 | |
| 20 | \begin{funcdesc}{UserList}{\optional{list}} |
| 21 | Return a class instance that simulates a list. The instance's |
| 22 | contents are kept in a regular list, which is accessible via the |
| 23 | \code{data} attribute of \code{UserList} instances. The instance's |
| 24 | contents are initially set to c copy of \var{list}, defaulting to the |
| 25 | empty list \code{[]}. \var{list} can be either a regular Python list, |
| 26 | or an instance of \code{UserList} (or a subclass). |
| 27 | \end{funcdesc} |