blob: 321f94fb41cb8d2fa58251bc1f1f8392e94251ee [file] [log] [blame]
Fred Drake3a0351c1998-04-04 07:23:21 +00001\section{Standard Modules \module{UserDict} and \module{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
Fred Drake19479911998-02-13 06:58:54 +000014\setindexsubitem{(in module UserDict)}
Fred Drake802a2021998-02-19 06:26:35 +000015The \module{UserDict} module defines the \class{UserDict} class:
Guido van Rossum7f3b0421997-03-27 14:56:18 +000016
Fred Drake802a2021998-02-19 06:26:35 +000017\begin{classdesc}{UserDict}{}
Guido van Rossum7f3b0421997-03-27 14:56:18 +000018Return a class instance that simulates a dictionary. The instance's
19contents are kept in a regular dictionary, which is accessible via the
Fred Drake802a2021998-02-19 06:26:35 +000020\member{data} attribute of \class{UserDict} instances.
21\end{classdesc}
Guido van Rossum7f3b0421997-03-27 14:56:18 +000022
Fred Drake19479911998-02-13 06:58:54 +000023\setindexsubitem{(in module UserList)}
Fred Drake802a2021998-02-19 06:26:35 +000024The \module{UserList} module defines the \class{UserList} class:
Guido van Rossum7f3b0421997-03-27 14:56:18 +000025
Fred Drake802a2021998-02-19 06:26:35 +000026\begin{classdesc}{UserList}{\optional{list}}
Guido van Rossum7f3b0421997-03-27 14:56:18 +000027Return a class instance that simulates a list. The instance's
28contents are kept in a regular list, which is accessible via the
Fred Drake802a2021998-02-19 06:26:35 +000029\member{data} attribute of \class{UserList} instances. The instance's
Fred Drakefcda5601998-01-07 22:05:25 +000030contents are initially set to a copy of \var{list}, defaulting to the
Guido van Rossum7f3b0421997-03-27 14:56:18 +000031empty list \code{[]}. \var{list} can be either a regular Python list,
Fred Drake802a2021998-02-19 06:26:35 +000032or an instance of \class{UserList} (or a subclass).
33\end{classdesc}