The Quick Python Book, Second Edition
Revised edition of The Quick Python Book by Daryl K. Harms and Kenneth M. McDonald
Naomi R. Ceder
  • December 2009
  • ISBN 9781935182207
  • 360 pages

The quickest way to learn the basics of Python.

Massimo Perga, Microsoft

This revision of Manning's popular The Quick Python Book offers a clear, crisp introduction to the elegant Python programming language and its famously easy-to-read syntax. Written for programmers new to Python, this updated edition covers features common to other languages concisely, while introducing Python's comprehensive standard functions library and unique features in detail.

After exploring Python's syntax, control flow, and basic data structures, the book shows how to create, test, and deploy full applications and larger code libraries. It addresses established Python features as well as the advanced object-oriented options available in Python 3. Along the way, you'll survey the current Python development landscape, including GUI programming, testing, database access, and web frameworks.

Table of Contents detailed table of contents



about this book

Part 1 Starting out

1. About Python

1.1. Why should I use Python?

1.2. What Python does well

1.3. What Python doesn?t do as well

1.4. Why learn Python 3?

1.5. Summary

2. Getting started

2.1. Installing Python

2.2. IDLE and the basic interactive mode

2.3. Using IDLE?s Python Shell window

2.4. Hello, world

2.5. Using the interactive prompt to explore Python

2.6. Summary

3. The Quick Python overview

3.1. Python synopsis

3.2. Built-in data types

3.3. Control flow structures

3.4. Module creation

3.5. Object-oriented programming

3.6. Summary

Part 2 The essentials

4. The absolute basics

4.1. Indentation and block structuring

4.2. Differentiating comments

4.3. Variables and assignments

4.4. Expressions

4.5. Strings

4.6. Numbers

4.7. The None value

4.8. Getting input from the user

4.9. Built-in operators

4.10. Basic Python style

4.11. Summary

5. Lists, tuples, and sets

5.1. Lists are like arrays

5.2. List indices

5.3. Modifying lists

5.4. Sorting lists

5.5. Other common list operations

5.6. Nested lists and deep copies

5.7. Tuples

5.8. Sets

5.9. Summary

6. Strings

6.1. Strings as sequences of characters

6.2. Basic string operations

6.3. Special characters and escape sequences

6.4. String methods

6.5. Converting from objects to strings

6.6. Using the format method

6.7. Formatting strings with %

6.8. Bytes

6.9. Summary

7. Dictionaries

7.1. What is a dictionary?

7.2. Other dictionary operations

7.3. Word counting

7.4. What can be used as a key?

7.5. Sparse matrices

7.6. Dictionaries as caches

7.7. Efficiency of dictionaries

7.8. Summary

8. Control flow

8.1. The while loop

8.2. The if-elif-else statement

8.3. The for loop

8.4. List and dictionary comprehensions

8.5. Statements, blocks, and indentation

8.6. Boolean values and expressions

8.7. Writing a simple program to analyze a text file

8.8. Summary

9. Functions

9.1. Basic function definitions

9.2. Function parameter options

9.3. Mutable objects as arguments

9.4. Local, nonlocal, and global variables

9.5. Assigning functions to variables

9.6. lambda expressions

9.7. Generator functions

9.8. Decorators

9.9. Summary

10. Modules and scoping rules

10.1. What is a module?

10.2. A first module

10.3. The import statement

10.4. The module search path

10.5. Private names in modules

10.6. Library and third-party modules

10.7. Python scoping rules and namespaces

10.8. Summary

11. Python programs

11.1. Creating a very basic program

11.2. Making a script directly executable on UNIX

11.3. Scripts on Mac OS X

11.4. Script execution options in Windows

11.5. Scripts on Windows vs. scripts on UNIX

11.6. Programs and modules

11.7. Distributing Python applications

11.8. Summary

12. Using the filesystem

12.1. Paths and pathnames

12.2. Getting information about files

12.3. More filesystem operations

12.4. Processing all files in a directory subtree

12.5. Summary

13. Reading and writing files

13.1. Opening files and file objects

13.2. Closing files

13.3. Opening files in write or other modes

13.4. Functions to read and write text or binary data

13.5. Screen input/output and redirection

13.6. Reading structured binary data with the struct module

13.7. Pickling objects into files

13.8. Shelving objects

13.9. Summary

14. Exceptions

14.1. Introduction to exceptions

14.2. Exceptions in Python

14.3. Using with

14.4. Summary

15. Classes and object-oriented programming

15.1. Defining classes

15.2. Instance variables

15.3. Methods

15.4. Class variables

15.5. Static methods and class methods

15.6. Inheritance

15.7. Inheritance with class and instance variables

15.8. Private variables and private methods

15.9. Using @property for more flexible instance variables

15.10. Scoping rules and namespaces for class instances

15.11. Destructors and memory management

15.12. Multiple inheritance

15.13. Summary

16. Graphical user interfaces

16.1. Installing Tkinter

16.2. Starting Tk and using Tkinter

16.3. Principles of Tkinter

16.4. A simple Tkinter application

16.5. Creating widgets

16.6. Widget placement

16.7. Using classes to manage Tkinter applications

16.8. What else can Tkinter do?

16.9. Alternatives to Tkinter

16.10. Summary

Part 3 Advanced language features

17. Regular expressions

17.1. What is a regular expression?

17.2. Regular expressions with special characters

17.3. Regular expressions and raw strings

17.4. Extracting matched text from strings

17.5. Substituting text with regular expressions

17.6. Summary

18. Packages

18.1. What is a package?

18.2. A first example

18.3. A concrete example

18.4. The all attribute

18.5. Proper use of packages

18.6. Summary

19. Data types as objects

19.1. Types are objects, too

19.2. Using types

19.3. Types and user-defined classes

19.4. Duck typing

19.5. Summary

20. Advanced object-oriented features

20.1. What is a special method attribute?

20.2. Making an object behave like a list

20.3. Giving an object full list capability

20.4. Subclassing from built-in types

20.5. When to use special method attributes

20.6. Metaclasses

20.7. Abstract base classes

20.8. Summary

Part 4 Where can you go from here?

21. Testing your code made easy(-er)

21.1. Why you need to have tests

21.2. The assert statement

21.3. Tests in docstrings: doctests

21.4. Using unit tests to test everything, every time

21.5. Summary

22. Moving from Python 2 to Python 3

22.1. Porting from 2 to 3

22.2. Testing with Python 2.6 and -3

22.3. Using 2to3 to convert the code

22.4. Testing and common problems

22.5. Using the same code for 2 and 3

22.6. Summary

23. Using Python libraries

23.1. ?Batteries included??the standard library

23.2. Moving beyond the standard library

23.3. Adding more Python libraries

23.4. Installing Python libraries using

23.5. PyPI, a.k.a. ?the Cheese Shop?

23.6. Summary 289

24. Network, web, and database programming

24.1. Accessing databases in Python

24.2. Network programming in Python

24.3. Creating a Python web application

24.4. Sample project?creating a message wall

24.5. Summary

Appendix A: appendix


© 2014 Manning Publications Co.

What's inside

  • Concepts and Python 3 features
  • Regular expressions and testing
  • Python tools
  • All the Python you need—nothing you don't

About the author

Second edition author Naomi Ceder is Director of Technology at the Canterbury School in Fort Wayne, Indiana, where she teaches and uses Python. The first edition of this book was written by Daryl Harms and Kenneth McDonald.

placing your order...

Don't refresh or navigate away from the page.

FREE domestic shipping on three or more pBooks