6.18. Related Modules

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.

Table 6.11. Related Modules for Sequence Types
ModuleContents
arrayfeatures the array restricted mutable sequence type which requires all of its elements to be of the same type
copyprovides functionality to perform shallow and deep copies of objects (see 6.19 below for more information)
operatorcontains sequence operators available as function calls, i.e. operator.concat(m, n) is equivalent to the concatenation (m + n) for sequences m and n.
typescontains type objects for all supported Python types
UserListwraps a list object (including operators and methods) into a class which can be used for derivation (also see Section 6.18)

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset