Organization of This Book
This book falls into five distinct parts. To manage the clue
absorption rate, the first three parts are organized in a way that
builds up the language in layers from central concepts to more advanced
features. Each layer introduces a few new concepts, and is presented in
some depth. Programming exercises are provided to encourage further
exploration of each layer. The last two parts cover the extension
modules and provide specifications for some complex exercises that will
help solidify programming skills.
Some of the chapters include digressions on more advanced topics.
These can be skipped, as they cover topics related to programming in
general, or notes about the implementation of the Python language. These
are reference material to help advanced students build skills above and
beyond the basic language.
Part I, “Language Basics” introduces the basic feartures of the
Python language, covering most of the statements but sticking with basic
numeric data types. Chapter 1, Background and History
provides some history
and background on Python. Chapter 3, Getting Started
covers
installation of Python, using the interpreter interactively and creating
simple program files. Chapter 4, Simple Numeric Expressions and Output
covers the basic
expressions and core numeric types. Chapter 6, Variables, Assignment and Input
introduces variables, assignment and some simple input constructs. Chapter 7, Truth, Comparison and Conditional
Processing
adds truth, conditions and loops to the language.
Chapter 9, Functions
introduces the basic function definition
and function call constructs; Chapter 10, Additional Notes On Functions
introduces
the call by name and call by value features of Python, as well as
advanced function call features.
Part II, “Data Structures” adds a number of data structures to
enhance the expressive power of the language. In this part we will use a
number of different kinds of objects, prior to designing our own
objects. Chapter 11, Sequences: Strings, Tuples and Lists
extends the data types to include
various kinds of sequences. These include Chapter 12, Strings
, Chapter 13, Tuples
and
Chapter 14, Lists
. Chapter 15, Mappings and Dictionaries
describes
mappings and dictionaries. Chapter 17, Exceptions
covers
exception objects, and exception creation and handling. Chapter 19, Files
covers files and several closely related
operating system (OS) services. Chapter 20, Advanced Sequences
describes
more advanced sequence techniques, including multi-dimensional matrix
processing. This part attempts to describe a reasonably complete set of
built-in data types.
Part III, “Data + Processing = Objects” describes the object-oriented
programming features of Python. Chapter 21, Classes
introduces basics of class definitions and introduces simple
inheritance. Chapter 22, Advanced Class Definition
adds some features to
basic class definitions. Chapter 23, Some Design Patterns
extend this
discussion further to include several common design patterns that use
polymorphism. Chapter 24, Creating or Extending Data Types
describes the mechanism
for adding types to Python that behave like the built-in types.
Part IV, “Components, Modules and Packages” describes modules, which provide a
higher-level grouping of class and function definitions. It also
summarizes selected extension modules provided with the Python
environment. Chapter 28, Modules
provides basic semantics
and syntax for creating modules. We cover the organization of packages
of modules in Chapter 29, Packages
. An overview of the
Python library is the subject of Chapter 30, The Python Library
. Chapter 31, Complex Strings: the re
Module
covers string pattern matching and processing with the
re
module. Chapter 32, Dates and Times: the time
and
datetime
Modules
covers the
time
and datetime
module.
Chapter 35, Programs: Standing Alone
covers the creation of main
programs. We touch just the tip of the client-server iceberg in Chapter 36, Programs: Clients, Servers, the Internet and the World Wide
Web
.
Some of the commonly-used modules are covered during earlier
chapters. In particular the math
and
random
modules are covered in the section called “The math
Module” and the string
module
is covered in Chapter 12, Strings
. Chapter 19, Files
touches on fileinput
,
os
, os.path
,
glob
, and fnmatch
.
Part V, “Projects” presents several larger and more
complex programming problems. These are ranked from relatively simple to
quite complex. Chapter 37, Areas of the Flag
covers computing the
area of the symbols on the American flag. Chapter 38, The Date of Easter
has several algorithms for finding the date
for Easter in a given year. Chapter 39, Musical Pitches
has
several algorithms for the exact frequencies of musical pitches. Chapter 40, Bowling Scores
covers scoring in a game of bowling. Chapter 41, Mah Jongg Hands
describes algorithms for evaluating hands
in the game of Maj Jongg. Chapter 42, Chess Game Notation
deals with
interpreting the log from a game of chess.