Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 1 | \section{\module{UserDict} --- |
Fred Drake | 6bf37de | 1999-06-29 18:13:37 +0000 | [diff] [blame] | 2 | Class wrapper for dictionary objects} |
| 3 | |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 4 | \declaremodule{standard}{UserDict} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 5 | \modulesynopsis{Class wrapper for dictionary objects.} |
| 6 | |
Fred Drake | 1ce3604 | 1998-04-07 20:05:33 +0000 | [diff] [blame] | 7 | This module defines a class that acts as a wrapper around |
| 8 | dictionary objects. It is a useful base class for |
| 9 | your own dictionary-like classes, which can inherit from |
Guido van Rossum | 7f3b042 | 1997-03-27 14:56:18 +0000 | [diff] [blame] | 10 | them and override existing methods or add new ones. In this way one |
Fred Drake | 1ce3604 | 1998-04-07 20:05:33 +0000 | [diff] [blame] | 11 | can add new behaviours to dictionaries. |
Guido van Rossum | 7f3b042 | 1997-03-27 14:56:18 +0000 | [diff] [blame] | 12 | |
Fred Drake | 802a202 | 1998-02-19 06:26:35 +0000 | [diff] [blame] | 13 | The \module{UserDict} module defines the \class{UserDict} class: |
Guido van Rossum | 7f3b042 | 1997-03-27 14:56:18 +0000 | [diff] [blame] | 14 | |
Fred Drake | 802a202 | 1998-02-19 06:26:35 +0000 | [diff] [blame] | 15 | \begin{classdesc}{UserDict}{} |
Guido van Rossum | 7f3b042 | 1997-03-27 14:56:18 +0000 | [diff] [blame] | 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 |
Fred Drake | 802a202 | 1998-02-19 06:26:35 +0000 | [diff] [blame] | 18 | \member{data} attribute of \class{UserDict} instances. |
| 19 | \end{classdesc} |
Guido van Rossum | 7f3b042 | 1997-03-27 14:56:18 +0000 | [diff] [blame] | 20 | |
Fred Drake | 6bf37de | 1999-06-29 18:13:37 +0000 | [diff] [blame] | 21 | In addition to supporting the methods and operations of mappings (see |
| 22 | section \ref{typesmapping}), \class{UserDict} instances provide the |
| 23 | following attribute: |
| 24 | |
Fred Drake | 1ce3604 | 1998-04-07 20:05:33 +0000 | [diff] [blame] | 25 | \begin{memberdesc}{data} |
| 26 | A real dictionary used to store the contents of the \class{UserDict} |
| 27 | class. |
| 28 | \end{memberdesc} |
| 29 | |
| 30 | |
Fred Drake | 295da24 | 1998-08-10 19:42:37 +0000 | [diff] [blame] | 31 | \section{\module{UserList} --- |
Fred Drake | 6bf37de | 1999-06-29 18:13:37 +0000 | [diff] [blame] | 32 | Class wrapper for list objects} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 33 | |
Fred Drake | 6bf37de | 1999-06-29 18:13:37 +0000 | [diff] [blame] | 34 | \declaremodule{standard}{UserList} |
Fred Drake | b91e934 | 1998-07-23 17:59:49 +0000 | [diff] [blame] | 35 | \modulesynopsis{Class wrapper for list objects.} |
| 36 | |
Fred Drake | 1ce3604 | 1998-04-07 20:05:33 +0000 | [diff] [blame] | 37 | |
| 38 | This module defines a class that acts as a wrapper around |
| 39 | list objects. It is a useful base class for |
| 40 | your own list-like classes, which can inherit from |
| 41 | them and override existing methods or add new ones. In this way one |
| 42 | can add new behaviours to lists. |
| 43 | |
Fred Drake | 802a202 | 1998-02-19 06:26:35 +0000 | [diff] [blame] | 44 | The \module{UserList} module defines the \class{UserList} class: |
Guido van Rossum | 7f3b042 | 1997-03-27 14:56:18 +0000 | [diff] [blame] | 45 | |
Fred Drake | 802a202 | 1998-02-19 06:26:35 +0000 | [diff] [blame] | 46 | \begin{classdesc}{UserList}{\optional{list}} |
Guido van Rossum | 7f3b042 | 1997-03-27 14:56:18 +0000 | [diff] [blame] | 47 | Return a class instance that simulates a list. The instance's |
| 48 | contents are kept in a regular list, which is accessible via the |
Fred Drake | 802a202 | 1998-02-19 06:26:35 +0000 | [diff] [blame] | 49 | \member{data} attribute of \class{UserList} instances. The instance's |
Fred Drake | fcda560 | 1998-01-07 22:05:25 +0000 | [diff] [blame] | 50 | 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] | 51 | empty list \code{[]}. \var{list} can be either a regular Python list, |
Fred Drake | 802a202 | 1998-02-19 06:26:35 +0000 | [diff] [blame] | 52 | or an instance of \class{UserList} (or a subclass). |
| 53 | \end{classdesc} |
Fred Drake | 1ce3604 | 1998-04-07 20:05:33 +0000 | [diff] [blame] | 54 | |
Fred Drake | 6bf37de | 1999-06-29 18:13:37 +0000 | [diff] [blame] | 55 | In addition to supporting the methods and operations of mutable |
| 56 | sequences (see section \ref{typesseq}), \class{UserList} instances |
| 57 | provide the following attribute: |
| 58 | |
Fred Drake | 1ce3604 | 1998-04-07 20:05:33 +0000 | [diff] [blame] | 59 | \begin{memberdesc}{data} |
| 60 | A real Python list object used to store the contents of the |
| 61 | \class{UserList} class. |
| 62 | \end{memberdesc} |