<= Return to book index
Welcome to Python!
Style:Technical, Yet Easy Reading
Author's Experience with Python
Book Contents
Part I : Core Python
Chapter 1 —Welcome to Python!
Chapter 2 —Getting Started
Chapter 3 —Syntax and Style
Chapter 4 —Python Objects
Chapter 5 —Numbers
Chapter 6 —Sequences: Strings, Lists, and Tuples
Chapter 7 —Dictionaries
Chapter 8 —Conditionals and Loops
Chapter 9 —Files and Input/Output
Chapter 10 —Errors and Exceptions
Chapter 11 —Functions
Chapter 12 —Modules
Chapter 13 —Classes and OOP
Chapter 14 —Execution Environment
Part II : Advanced Topics
Chapter 15 —Regular Expressions
Chapter 16 —Network Programming with Sockets
Chapter 17 —Multithreaded Programming
Chapter 18 —GUI Programming with Tkinter
Chapter 19 —Web Programming
Chapter 20 —Extending Python
Optional Sections
Conventions
Book Support
Acknowledgements
I: CORE PYTHON
1. Welcome to Python!
What Is Python?
History of Python
Features of Python
Obtaining Python
Obtaining Python
Installing Python
Running Python
Python Documentation
Comparing Python
JPython and Some Nomenclature
Exercises
2. Getting Started
Program Output, the print Statement, and "Hello World!"
Program Input and the raw_input() Built-in Function
Comments
Operators
Variables and Assignment
Numbers
Strings
Lists and Tuples
Dictionaries
Code Blocks Use Indentation
if Statement
while Loop
for Loop and the range() Built-in Function
Files and the open() Built-in Function
Errors and Exceptions
Functions
Classes
Modules
Exercises
3. Syntax and Style
Statements and Syntax
Variable Assignment
Identifiers
Basic Style Guidelines
Memory Management
First Python Application
Exercises
4. Python Objects
Python Objects
Standard Types
Other Built-in Types
Internal Types
Standard Type Operators
Standard Type Built-in Functions
Categorizing the Standard Types
Unsupported Types
Exercises
5. Numbers
Introduction to Numbers
Integers
Floating Point Real Numbers
Complex Numbers
Operators
Built-in Functions
Related Modules
Exercises
6. Sequences: Strings, Lists, and Tuples
Sequences
Strings
Strings and Operators
String-only Operators
Built-in Functions
String Built-in Methods
Special Features of Strings
Related Modules
Summary of String Highlights
Lists
Operators
Built-in Functions
List Type Built-in Methods
Special Features of Lists
Tuples
Tuple Operators and Built-in Functions
Special Features of Tuples
Related Modules
*Shallow and Deep Copies
Exercises
7. Dictionaries
Introduction to Dictionaries
Operators
Built-in Functions
Built-in Methods
Dictionary Keys
Exercises
8. Conditionals and Loops
if statement
else Statement
elif (a.k.a. else-if ) Statement
while Statement
for Statement
break Statement
continue Statement
pass Statement
else Statement… Take Two
Exercises
9. Files and Input/Output
File Objects
File Built-in Function [ open() ]
File Built-in Methods
File Built-in Attributes
Standard Files
Command-line Arguments
File System
File Execution
Persistent Storage Modules
Related Modules
Exercises
10. Errors And Exceptions
What Are Exceptions?
Exceptions in Python
Detecting and Handling Exceptions
*Exceptions as Strings
*Exceptions as Classes
Raising Exceptions
Assertions
Standard Exceptions
*Creating Exceptions
Why Exceptions (Now)?
Why Exceptions at All?
Exceptions and the sys Module
Related Modules
Exercises
11. Functions
What Are Functions?
Calling Functions
Creating Functions
Passing Functions
Formal Arguments
Positional Arguments
Default Arguments
Why Default Arguments?
Default Function Object Argument Example
Variable-length Arguments
Non-keyword Variable Arguments (Tuple)
Keyword Variable Arguments (Dictionary)
Calling Functions with Variable Argument Objects
Functional Programming
Anonymous Functions and lambda
Built-in Functions: apply(), filter(), map(), reduce()
* apply()
Lines 1 - 4
Lines 6 - 7
Lines 9 - 28
Lines 30-41
filter()
map()
reduce()
Variable Scope
*Recursion
Exercises
12. Modules
What are Modules?
Modules and Files
Namespaces
Importing Modules
Importing Module Attributes
Module Built-in Functions
Packages
Other Features of Modules
Exercises
13. Classes and OOP
Introduction
Object-oriented Programming
Classes
Class Attributes
Instances
Instance Attributes
Binding and Method Invocation
Composition
Subclassing and Derivation
Inheritance
Built-in Functions for Classes, Instances, and Other Objects
Type vs. Classes/Instances
Customizing Classes with Special Methods
Privacy
Delegation
Related Modules and Documentation
Exercises
14. Execution Environment
Callable Objects
Code Objects
Executable Object Statements and Built-in Functions
Executing Other (Python) Programs
Executing Other (Non-Python) Programs
Restricted Execution
Terminating Execution
Related Modules
Exercises
II: Advanced Topics
15. Regular Expressions
Introduction/Motivation
Special Symbols and Characters for REs
REs and Python
Regular Expression Adventures
Exercises
16. Network Programming
Introduction
Sockets: Communication Endpoints
Network Programming in Python
Related Modules
Exercises
17. Multithreaded Programming
Introduction/Motivation
Threads and Processes
Threads and Python
thread Module
threading Module
Exercises
18. GUI Programming with Tkinter
Introduction
Tkinter and Python Programming
Tkinter Examples
Related Modules and Other GUIs
Exercises
19. Web Programming
Introduction
Web Surfing with Python: Creating Simple Web Clients
Advanced Web Clients
CGI: Helping Web Servers Process Client Data
Building CGI Application
Advanced CGI
Web (HTTP) Servers
Related Modules
Exercises
20. Extending Python
Introduction/Motivation
Related Topics
Exercises
A.
Answers to Selected Exercises
B.
Other Reading and References
Other Printed References
Online References
C.
Python Operator Summary
D.
What's New in Python 2.0?