Table6.11 lists the key related modules for sequence types. This list includes the array module to which we briefly alluded earlier. These are similar to lists except for the restriction that all elements must be of the same type. The copy module (see optional Section 6.19 below) performs shallow and deep copies of objects. The operator module, in addition to the functional equivalents to numeric operators, also contains the same four sequence types. The types module is a reference of type objects representing all types which Python supports, including sequence types. Finally, the UserList module contains a full class implementation of a list object. Because Python types cannot be subclassed, this module allows users to obtain a class that is list-like in nature, and derive new classes or functionality. If you are unfamiliar with object-oriented programming, we highly recommend reading Chapter 13.
Module | Contents |
---|---|
array | features the array restricted mutable sequence type which requires all of its elements to be of the same type |
copy | provides functionality to perform shallow and deep copies of objects (see 6.19 below for more information) |
operator | contains sequence operators available as function calls, i.e. operator.concat(m, n) is equivalent to the concatenation (m + n) for sequences m and n. |
types | contains type objects for all supported Python types |
UserList | wraps a list object (including operators and methods) into a class which can be used for derivation (also see Section 6.18) |