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