blob: 099334ea7b3fad29df0dea878e28da22283bf3d5 [file] [log] [blame]
Guido van Rossum7f3b0421997-03-27 14:56:18 +00001\section{Standard Modules \sectcode{UserDict} and \sectcode{UserList}}
Guido van Rossum692b87d1998-02-11 23:00:08 +00002\nodename{UserDict and UserList}
Fred Drakefcda5601998-01-07 22:05:25 +00003\stmodindex{UserDict}
Guido van Rossum692b87d1998-02-11 23:00:08 +00004\stmodindex{UserList}
Fred Drakefcda5601998-01-07 22:05:25 +00005\label{module-UserDict}
6\label{module-UserList}
7
Guido van Rossum7f3b0421997-03-27 14:56:18 +00008Each of these modules defines a class that acts as a wrapper around
9either dictionary or list objects. They're useful base classes for
10your own dictionary-like or list-like classes, which can inherit from
11them and override existing methods or add new ones. In this way one
12can add new behaviours to dictionaries or lists.
13
14\renewcommand{\indexsubitem}{(in module UserDict)}
15The \code{UserDict} module defines the \code{UserDict} class:
16
17\begin{funcdesc}{UserDict}{}
18Return a class instance that simulates a dictionary. The instance's
19contents are kept in a regular dictionary, which is accessible via the
20\code{data} attribute of \code{UserDict} instances.
21\end{funcdesc}
22
Fred Drakefcda5601998-01-07 22:05:25 +000023\stmodindex{UserList}
Guido van Rossum7f3b0421997-03-27 14:56:18 +000024\renewcommand{\indexsubitem}{(in module UserList)}
25The \code{UserList} module defines the \code{UserList} class:
26
27\begin{funcdesc}{UserList}{\optional{list}}
28Return a class instance that simulates a list. The instance's
29contents are kept in a regular list, which is accessible via the
30\code{data} attribute of \code{UserList} instances. The instance's
Fred Drakefcda5601998-01-07 22:05:25 +000031contents are initially set to a copy of \var{list}, defaulting to the
Guido van Rossum7f3b0421997-03-27 14:56:18 +000032empty list \code{[]}. \var{list} can be either a regular Python list,
33or an instance of \code{UserList} (or a subclass).
34\end{funcdesc}