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