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