3.3 Standard Modules UserDict and UserList

         

Each of these modules defines a class that acts as a wrapper around either dictionary or list objects. They're useful base classes for your own dictionary-like or list-like classes, which can inherit from them and override existing methods or add new ones. In this way one can add new behaviours to dictionaries or lists.

The UserDict module defines the UserDict class:

UserDict ()
Return a class instance that simulates a dictionary. The instance's contents are kept in a regular dictionary, which is accessible via the data attribute of UserDict instances.

The UserList module defines the UserList class:

UserList ([list])
Return a class instance that simulates a list. The instance's contents are kept in a regular list, which is accessible via the data attribute of UserList instances. The instance's contents are initially set to a copy of list, defaulting to the empty list []. list can be either a regular Python list, or an instance of UserList (or a subclass).



guido@python.org