The Quick Python Book

A Guide to Learning and Effectively Using the Python Language

Daryl Dean Harms, Kenneth McDonald

Publisher: Manning, 2000, 422 pages

ISBN: 1-884777-74-0

Keywords: Python

Last modified: Nov. 9, 2008, 11:32 a.m.

This book is a clear and easy-to-read introduction to the Python language and to useful advanced topics. Python is a language that helps you write programs quickly. This book will help you master the Python language quickly.

The book first covers the core features of the language: syntax, control flow, basic data structures. Features in common with other languages are covered concisely; features unique to Python are explained in detail. Then it discusses Python features which would be useful in larger applications: managing large collections of code, object-oriented programming, advanced string handling, etc. Next are chapters on special topics by Python experts including the inventor of the language, Guido van Rossum.

The book concludes with a compact but extensive reference to the Python core language and to many of its advanced features. With it, you'll be using Python more quickly than you thought possible.

  • Part 1 Starting out
    1. About Python
      1. Why should I use it?
      2. A look at languages
      3. A comparison of Python and other languages
        • Python versus C, Pascal, C++, and Java
        • Python versus Visual Basic, Python versus Tcl
        • Python versus Perl
      4. What's the catch?
      5. Have your language and Python too!
      6. Python and open source software
      7. Summary
    2. About this book
      1. How to use this book
        • Organization
        • Sidenotes
        • The alert marker
      2. Learning Python by example
      3. Formatting conventions for code examples
        • Interactive examples
        • Noninteractive examples
      4. What you will find in this book
      5. Where to find more information
      6. Feedback
    3. Getting started
      1. Installing Python
      2. IDLE and the basic interactive mode
        • The basic interactive mode
        • The IDLE Integrated Development Environment
      3. Hello, world
      4. Using IDLE's Python Shell window
  • Part 2 The essentials
    1. The Quick Python overview
      1. About this chapter
      2. Python synopsis
      3. Built-in data types
        • Numbers
        • Lists
        • Tuples
        • Strings
        • Dictionaries
        • File objects
      4. Control flow structures
        • Boolean values and expressions
        • The if-elif-else statement
        • The while loop
        • The for loop
        • Function definition
        • Exceptions
      5. Module creation
      6. Object-oriented programming
      7. Summary
    2. The absolute basics
      1. Indentation and block-structuring
      2. Comments
      3. Variables and assignments
      4. Expressions
      5. Strings
      6. Numbers
        • Built-in numeric functions
        • Advanced numeric functions
        • Numeric computation
        • Complex numbers
      7. The None value
      8. Built-in operators
    3. Lists and tuples
      1. Lists are like arrays
      2. List indices
      3. Modifying lists
      4. Sorting
        • Custom sorting
      5. Other common list operations
        • List membership with the in operator
        • List concatenation with the + operator
        • List initialization with the * operator
        • List minimum or maximum with min and max
        • List search with index
        • List matches with count
      6. Nested lists and deep copies
      7. Tuples
        • Tuple basics
        • Tuple packing and unpacking
        • Converting between lists and tuples
      8. Summary
    4. Strings
      1. Strings as sequences of characters
      2. Basic string operations
      3. Special characters and escape sequences
        • Basic escape sequences
        • Numeric (octal and hexadecimal) escape sequences
        • Printing vs. evaluating strings with special characters
      4. The "string" module
        • string.split and string.join
        • Converting strings to numbers
        • Getting rid of extra whitespace
        • String searching
        • Modifying strings
        • Modifying strings with list manipulations
        • Useful constants
      5. Converting from objects to strings
      6. Formatting strings
        • Using formatting sequences
        • Named parameters and formatting sequences
    5. Dictionaries
      1. What is a dictionary?
        • Why dictionaries are called dictionaries
      2. Other dictionary operations
      3. Word counting
      4. What can be used as a key?
      5. Sparse matrices
      6. Dictionaries as caches
      7. Efficiency of dictionaries
    6. 9 Control flow
      1. The while loop
      2. The if-elif-else statement
      3. The for loop
        • The range function
        • The for loop and tuple unpacking
      4. Statements, blocks, and indentation
      5. Boolean values and expressions
        • Most Python objects can be used as booleans
        • Comparison and boolean operators
    7. Functions and procedures
      1. Basic function and procedure definitions
      2. Assigning functions to variables
      3. Lambda expressions
      4. Function parameter options
        • Default values
        • Passing arguments by parameter name
        • Variable numbers of arguments
        • Mixing argument-passing techniques
      5. Mutable objects as arguments
      6. Local and global variables
      7. Summary
    8. Modules and scoping rules
      1. What is a module?
      2. A first module
      3. The import statement
      4. The module search path
        • Where to place your own modules
      5. Private names in modules
      6. Library and third-party modules
      7. Python scoping rules and namespaces
    9. Using the filesystem
      1. Paths and pathnames
        • Absolute and relative paths
        • The current working directory
        • Manipulating pathnames
        • Useful constants and functions
      2. Getting information about files
      3. More filesystem operations
      4. Processing all files in a directory subtree
      5. Summary
    10. Reading and writing files
      1. Opening files and file objects
      2. Closing files
      3. Opening files in write or other modes
      4. Functions to read and write text or binary data
      5. Screen input/output and redirection
      6. The struct module
      7. Pickling objects into files
      8. Shelving objects
      9.  Summary
    11. Exceptions
      1. Introduction to exceptions
        • General philosophy of errors and exception handling
        • A more formal definition of exceptions
        • User-defined exceptions
      2. Exceptions in Python
        • Types of Python exceptions
        • Raising exceptions
        • Catching and handling exceptions
        • Defining new exceptions
        • Debugging programs with the assert statement
        • The exception inheritance hierarchy
        • Example: our disk writing program in Python
        • Example: exceptions in normal evaluation
        • Where to use exceptions
    12. Scripts
      1. Creating a very basic script
        • Starting a script from a command line
        • Command line arguments
        • Redirecting the input and output of a script
        • The getopt module
        • Using the fileinput module
      2. Making a script directly executable on UNIX
      3. Script execution options in Windows
        • Starting a script as a document or shortcut
        • Starting a script from the Windows run box
        • Starting a script from an MS-DOS Prompt window
        • Other Windows options
      4. Scripts on Windows versus scripts on UNIX
      5. Scripts and modules
      6. Creating executable programs with freeze
      7. Summary
    13. Classes and object-oriented programming
      1. Defining classes
        • Using a class instance as a structure or record
        • Objects, class instances, and instances of other Python types
      2. Instance variables
      3. Methods
      4. Class variables
        • An oddity with class variables
      5. Class methods
      6. Inheritance
      7. Inheritance with class and instance variables
      8. Private variables and private methods
      9. Scoping rules and namespaces for class instances
      10. Destructors and memory management
      11. Multiple inheritance
      12. Summary
    14. Graphical User Interfaces and Tk
      1. Installing Tk
      2. Starting Tk and using Tkinter
      3. Principles of Tk
        • Widgets
        • Named attributes
        • Geometry management and widget placement
      4. A simple Tkinter application
      5. Creating widgets
      6. Widget placement
      7. What else can Tkinter do?
        • Event handling
        • Canvas and text widgets
        • Extensions to Tk and Tkinter
      8. Alternatives to Tk and Tkinter
      9. Summary
  • Part 3 Advanced language features
    1. Packages
      1. What is a package?
      2. A first example
      3. A concrete example
        • Basic use of the mathproj package
        • Loading subpackages and submodules
        • Import statements within packages
        • __init__.py files in packages
      4. The __all__ attribute
      5. Proper use of packages
    2. Data types as objects
      1. Types are objects, too
      2. Using types
      3. The types module
      4. Types and user-defined classes
    3. Special method attributes
      1. What is a special method attribute?
      2. Making an object behave like a list
        • The __getitem__ special method attribute
        • How it works
        • Implementing full list functionality
      3. Sample problem 2
      4. When to use special method attributes
    4. Regular expressions
      1. What is a regular expression?
      2. Regular expressions with metacharacters
      3. Regular expressions and raw strings
        • Raw strings to the rescue
      4. Extracting matched text from strings
      5. Substituting text with regular expressions
      6. What else can regular expressions do?
  • Part 4 Advanced topics and applications
    1. Python, Windows, and COM
      1. 22.1 Introduction
      2. How to use Python with COM
      3. Installation and setup
      4. Anatomy of a Python COM server
        • Importing the Python COM Modules
        • Setting up the Python COM server class
        • Writing server class methods
        • Registering the Python server class with COM
        • Test code
        • Creating a module body
        • The Python COM server template as a whole
      5. Creating and using the server from Visual Basic
        • Troubleshooting the server
        • Using the server
        • Server shutdown
      6. Passing data in and out of the server
        • Numbers
        • Strings
        • Retrieving lists
        • Passing in lists
        • Retrieving tabular data
        • More about variant arrays
        • Odd-shaped lists
        • Passing objects
      7. Callbacks
      8. Using Excel as a client
        • Setting up an Excel workbook with a server
        • Fetching data
        • What next?
      9. Distributed COM
      10. Client side COM—automating Office
        • Fetching data from Access
        • Update an Access record
        • Start Excel from Python, push in some data
        • Start Word, push in some data
      11. Type libraries
      12. Guidelines
      13. Other goodies
        • Windows Scripting Host
        • ODBC
        • MFC wrappers
        • Other Windows API wrappers
        • Call any DLL
      14. Sources of information
    2. Extending Python with C and C++
      1. Using this chapter
      2. Compilation details
        • Which compiler?
        • Shared versus static extensions
        • Compilation details for your system
      3. A first example
        • Putting it into a template
      4. Memory management
        • The need for memory management
        • A basic example
        • When are reference counts decremented?
        • Reference counting is a tricky business
      5. Writing extensions in C++
      6. Where to go from here
    3. Integration with the Java Virtual Machine: JPython
      1. What is JPython?
      2. Prologue: the false hope for a single language
        • So, what about Java?
      3. JPython, the killer scripting language
      4. Downloading and installing JPython
        • Test driving JPython
      5.  Using Java from JPython
        • Extending Java classes
      6. Using JPython from Java
      7. Compiling JPython classes
        • Notes on using jpythonc
      8. Using Java and JPython together
      9. Conclusion
    4. HTML and Python—the HTMLgen package
      1. Uses for HTMLgen
        • An HTMLgen example
      2. How HTMLgen renders objects
      3. Document model
        • Document class hierarchy
      4. Tables
        • Quick and dirty tables
        • Full table component version
      5. Lists
      6. Frames
      7. Images
      8. Image maps
      9. The <A> tag
      10. Call protocol
      11. CSS1 support
        • Advanced style features
      12. CGI and forms
        • CGI with the StickyForm class
        • CGI with Zope
      13. Auxiliary modules
      14. The future
    5. Using 'Zope'
      1. Introduction
      2. Object publishing
        • What is object publishing?
        • Object traversal: from URLs to object calls
        • Object publishing details
        • A simple example
        • Guest books and ad generators
      3. Advanced Zope
        • HTML generation with DocumentTemplate
        • Conditionals, sequences, and expressions
        • Object persistence with BoboPOS
        • More features
        • The Web Job Board
    6. What else can Python do?
    • Quick Python reference

Reviews

The Quick Python Book

Reviewed by Roland Buresund

Decent ****** (6 out of 10)

Last modified: June 11, 2008, 12:46 a.m.

Good, if dated primer on Python, if you're already a programmer.

If you don't already have experience in programming, this is not for you. Also, if you're looking for info on tk or a solid reference work on Python, skip this one. This learns programmers Python and does it good. An added extra is some Windows specific chapters (like COM).

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

captcha

required