Note:This module is available for backward compatibility only. Ifyou are writing code that does not need to work with versions ofPython earlier than Python 2.2, please consider subclassing directlyfrom the built-inlist type.
This module defines a class that acts as a wrapper aroundlist objects. It is a useful base class foryour own list-like classes, which can inherit fromthem and override existing methods or add new ones. In this way onecan add new behaviors to lists.
TheUserList module defines theUserList class:
[].list can be either a regular Python list,or an instance ofUserList (or a subclass).In addition to supporting the methods and operations of mutablesequences (see section2.2.6),UserList instancesprovide the following attribute:
Subclassing requirements:Subclasses ofUserList are expect to offer a constructor whichcan be called with either no arguments or one argument. Listoperations which return a new sequence attempt to create an instanceof the actual implementation class. To do so, it assumes that theconstructor can be called with a single parameter, which is a sequenceobject used as a data source.
If a derived class does not wish to comply with this requirement, allof the special methods supported by this class will need to beoverridden; please consult the sources for information about themethods which need to be provided in that case.
Changed in version 2.0:Python versions 1.5.2 and 1.6 also required that the constructor be callable with no parameters, and offer a mutabledata attribute. Earlier versions of Python did not attempt to create instances of the derived class.
| Python Library Reference |