Section 6.19. Related Modules


6.19. Related Modules

Table 6.12 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.20 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 that 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 to derive new classes or functionality. If you are unfamiliar with object-oriented programming, we highly recommend reading Chapter 13.

Table 6.12. Related Modules for Sequence Types

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.20 below for more information)

operator

Contains sequence operators available as function calls, e.g., operator.concat(m, n) is equivalent to the concatenation (m + n) for sequences m and n

re

Perl-style regular expression search (and match); see Chapter 15

StringIO/cStringIO

Treats long strings just like a file object, i.e., read(), seek(), etc.; C-compiled version is faster but cannot be subclassed

textwrap[a]

Utility functions for wrapping/filling text fields; also has a class

types

Contains type objects for all supported Python types

collections[b]

High-performance container data types


[a] New in Python 2.3.

[b] New in Python 2.4.



Core Python Programming
Core Python Programming (2nd Edition)
ISBN: 0132269937
EAN: 2147483647
Year: 2004
Pages: 334
Authors: Wesley J Chun

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net