* * Python Training Classes - In Chicago * *

with David Beazley
Author of the "Python Essential Reference"
Dabeaz LLC
5412 N Clark Street #218
Chicago, IL 60640

Target Audience: Intermediate

This class is for programmers who are already experienced with another programming language such as C, C++, Java, Perl, PHP, etc.

No experience with Python is assumed, but don't be misled by the word "Introduction." This is a serious hands-on course in which you will be writing programs, working with datafiles, and exploring a wide range of topics. Come ready to code. [ Am I prepared? ]

Price: $2500

What's Included?

  • A printed copy of the course notes.
  • A copy of the "Python Essential Reference, 4th Ed."
  • Lunch at local restaurants
  • Snacks
[ Register | More Information | FAQ]

Introduction To Python

[3 days] An intense no-bull Python course for programmers, sysadmins, scientists, and engineers who want to know how to use Python to solve all manner of practical problems. Topics are aimed at tasks that you face on a day-to-day basis. For example, analyzing data files, encoding/decoding various file formats, accessing databases, scraping web pages, automating system tasks, integrating Python with legacy software, and more. Even if you already know some Python, you will walk away from this course with new insight and ideas.

Major topics include:

  • An introduction to python
  • Working with data
  • Program organization and functions
  • Modules and libraries
  • Classes and objects
  • Testing, debugging, and profiling
  • Iterators and generators
  • Text processing and parsing
  • Files and the file system
  • Processes and subprocesses
  • XML parsing

Detailed Course Outline

Day 1

  1. Introduction to Python. An introduction to the Python programming language. Covers details of how to start and stop the interpreter and write programs. Introduces Python's basic datatypes, files, functions, and error handling.
  2. Working with Data. A detailed tour of how to represent and work with data in Python. Covers tuples, lists, dictionaries, and sets. Students will also learn how to effectively use Python's very powerful list processing primitives such as list comprehensions. Finally, this section covers critical aspects of Python's underlying object model including variables, reference counting, copying, and type checking.
  3. Program Organization and Functions. More information about how to organize larger programs into functions. A major focus of this section is on how to design functions that are reliable and can be easily reused in other settings. Also covers technical details of functions including scoping rules, documentation strings, and anonymous functions.

Day 2

  1. Modules and Libraries. How to organize programs into modules and details on using modules as a tool for creating extensible programs. This section concludes with a overview of some of the most commonly used library modules and instructions on how to install third party library modules. Some of the standard library modules covered in this section include those related to the file system and file handling, Tkinter (used to write GUIs), the Python database API (used to connect Python to relational database systems), and the logging module.
  2. Classes and Objects. An introduction to object-oriented programming in Python. Describes how to create new objects, overload operators, and utilize Python special methods. Also covers basic principles of object oriented programming including inheritance and composition.
  3. Inside the Python Object Model. A detailed look at how objects are implemented in Python. Major topics include object representation, attribute binding, inheritance, memory management, and special properties of classes including properties, slots, and private attributes.
  4. Testing, Debugging, and Software Development Practice. This section discusses many isses that are considered important to Python software development. This includes effective use of documentation strings, program testing using both the doctest and unittest modules, and effective use of assertions. The Python debugger and profiler are also described.

Day 3

  1. Iterators and Generators. Covers the iteration protocol, iterable objects, generators and generator expressions. A major focus of this section concerns the use of generators to set up data processing pipelines--a particularly effective technique for addressing a wide variety of common systems programming problems (e.g., processing large datafiles, handling infinite data streams, etc.).
  2. Working with Text. A more in-depth look at how to efficiently parse and generate text data in Python. Topics include string splitting, string stripping, string joining, and template strings. This section also covers the re module, Python's module for regular expression pattern matching and substitution.
  3. Binary Data Handling and File I/O. How to work with binary-encoded data in Python. Topics include binary file I/O as well as the struct and array modules.
  4. Python Integration Primer. A survey of how Python is able to interact with programs written in other programming languages. Topics include subprocesses, support for common data interchange formats (e.g., XML), network programming, accessing C code, COM extensions, Jython, and IronPython.
  5. Advanced Topics. An assortment of more advanced programming techniques. Topics include variable argument functions, anonymous functions and lambda, decorators, and packages.

Course Materials

Students will receive a bound 300-page fully indexed set of lecture notes along with a complete set of more than 50 class exercises (distributed electronically). All class exercises come with solution code for later study and for use during the class.

Slide Topic Index

The following table, generated automatically from the presentation slides, gives much more detail about the material to be covered. I am always making improvements to course material so this outline is subject to change at any time.

0. Course Setup

Course Setup0-1
Required Files0-2
Setting up Your Environment0-3
Class Exercises0-4
General Tips0-6
Using IDLE0-7
Running IDLE (Windows)0-8
Running IDLE (Mac/Unix)0-9

1. Introduction to Python

Introduction to Python1-1
Where to Get Python?1-2
What is Python?1-3
Why was Python Created?1-4
Python Influences1-5
Some Uses of Python1-6
Python Non-Uses1-7
Getting Started1-8
Running Python1-9
IDLE on Windows1-11
IDLE on other Systems1-12
The Python Interpreter1-13
Interactive Mode1-14
Interactive Mode in IDLE1-16
Getting Help1-17
Creating Programs1-19
Running Programs (IDLE)1-23
Running Programs1-24
A Sample Program1-25
An IDLE Caution1-29
Python 101 : Statements1-31
Python 101 : Comments1-32
Python 101: Variables1-33
Python 101: Keywords1-34
Python 101: Case Sensitivity1-35
Python 101: Looping1-36
Python 101 : Indentation1-37
Python 101 : Conditionals1-39
Python 101 : Relations1-40
Python 101 : Printing1-41
Python 101 : User Input1-42
Python 101 : pass statement1-43
Python 101 : Long Lines1-44
Basic Datatypes1-46
Booleans (bool)1-48
Integers (int)1-49
Long Integers (long)1-50
Integer Operations1-51
Integer Division1-52
Floating point (float)1-53
Floating point1-54
Floating Point Operators1-55
Converting Numbers1-56
String Escape Codes1-58
String Representation1-59
More String Operations1-61
String Methods1-62
More String Methods1-63
String Mutability1-64
String Conversions1-65
String Splitting1-67
Lists (cont)1-69
More List Operations1-70
List Removal1-71
List Sorting1-72
File Input and Output1-74
Looping over a file1-75
Type Conversion1-77
Simple Functions1-78
Library Functions1-79
Exception Handling1-80
dir() function1-83
dir() Example1-84

2. Working with Data

Working with Data2-1
Primitive Datatypes2-3
None type2-4
Data Structures2-5
Tuple Use2-7
Tuples (cont)2-8
Tuple Packing2-9
Tuple Unpacking2-10
Tuple Commentary2-11
Tuples vs. Lists2-12
Lists as a Container2-18
Dicts as a Container2-19
Dict : Looking For Items2-20
Dicts and Lists2-21
Formatted Output2-23
String Formatting2-24
Format Codes2-25
String Formatting2-26
Working with Sequences2-28
Sequence Slicing2-30
Extended Slices2-31
Sequence Reductions2-32
Iterating over a Sequence2-33
Iteration Variables2-34
break and continue2-35
Looping over integers2-36
Caution with range()2-37
enumerate() Function2-38
for and tuples2-40
zip() Function2-41
Using zip()2-43
List Processing2-45
List Comprehensions2-46
List Comp: Examples2-49
Historical Digression2-50
List Comp. and Awk2-51
Big Idea: Being Declarative2-52
More details on objects2-54
The Issue with Assignment2-55
Assignment Example2-56
Reassigning Values2-58
Some Dangers2-59
Identity and References2-60
Shallow Copies2-61
Deep Copying2-62
Names, Values, Types2-63
Type Checking2-64
Everything is an object2-65
First Class Objects2-66

3. Program Organization and Function

Program Organization and Functions3-1
What is a "Script?"3-4
Defining Things3-6
Defining Functions3-7
What is a function?3-8
Function Definitions3-9
Bottom-up Style3-10
A Definition Caution3-11
Function Design3-13
Function Arguments3-14
Default Arguments3-15
Calling a Function3-16
Keyword Arguments3-17
Mixed Arguments3-18
Design Tip3-19
Return Values3-22
Multiple Return Values3-23
Side Effects3-24
Design Tip3-25
Understanding Variables3-26
Local Variables3-27
Global Variables3-28
Modifying Globals3-29
Design Tip3-31
More on Functions3-33
Error Checking3-34
Documentation Strings3-37
Docstring Benefits3-38
Exception Values3-45
Syntax Caution3-46
Catching Multiple Errors3-47
Catching All Errors3-48
Exploding Heads3-49
A Better Approach3-50
finally statement3-51
Program Exit3-52

4. Modules and Libraries

Modules and Libraries4-1
Globals Revisited4-5
Common Confusion4-6
Module Execution4-7
Main Functions4-8
Main Module4-9
__main__ check4-10
Module Loading4-12
Locating Modules4-13
Module Search Path4-14
Import Process4-15
Using Modules4-17
Modules are Objects4-18
What is a Module?4-19
import as statement4-20
from module import4-22
from module import *4-23
Be Explicit4-25
Globals, Once More4-26
Standard Library4-28
sys module4-29
sys: Standard I/O4-30
sys: Command Line Opts4-31
Command Line Args4-32
math module4-33
copy Module4-34
os Module4-35
Environment Variables4-36
Getting a Directory Listing4-37
os.path Module4-38
File Tests4-39
File Metadata4-41
Directory Walking4-42
Shell Operations (shutil)4-43
time module4-44
datetime module4-45
pickle Module4-47
shelve module4-49
sqlite3 Module4-50
sqlite3 Example4-51
sqlite3 Module4-53
Third Party Modules4-56
Some Notable Modules4-57
Installing Modules4-58
Platform Native Install4-59
OS Package Manager4-60
Manual Installation4-61

5. Classes and Objects

Classes and Objects5-1
OO in a Nutshell5-3
The class statement5-4
__init__ method5-6
Instance Data5-7
Calling Other Methods5-9
Inheritance Example5-13
Using Inheritance5-15
object base class5-16
Inheritance and 5-17
Inheritance and methods5-18
Calling Other Methods5-19
Multiple Inheritance5-20
Special Methods5-22
Methods: String Conv.5-23
Methods: Item Access5-24
Methods: Containment5-25
Methods: Mathematics5-26
Odds and Ends5-27
Defining Exceptions5-28
Method Invocation5-29
Bound Methods5-30
Unbound Methods5-31
Attribute Accesss5-32

6. The Inner Workings of Python Objects

The Inner Workings of Python Objects6-1
Dictionaries Revisited6-3
Dicts and Functions6-4
Dicts and Modules6-5
Dicts and Objects6-6
Dicts and Instances6-7
Dicts and Classes6-9
Instances and Classes6-10
Attribute Access6-12
Modifying Instances6-13
Reading Attributes6-15
How Inheritance Works6-18
Reading Attributes6-19
Single Inheritance6-20
Multiple Inheritance6-21
Classes and Encapsulation6-23
A Problem6-24
Python Encapsulation6-25
Private Attributes6-26
Private Methods6-27
Accessor Methods6-28
Uniform Access6-33
__slots__ Attribute6-36
Memory Management6-38
Instance Creation6-39
__new__() method6-40
Instance Deletion6-41
Object Deletion: Cycles6-42
Garbage Collection6-43
__del__ method6-44

7. Testing and Debugging

Testing and Debugging7-1
Testing Rocks, Debugging Sucks7-3
Testing: doctest module7-4
Using doctest7-5
Testing: unittest7-9
Using unittest7-10
Running unittests7-13
unittest comments7-14
logging Module7-16
Exceptions Revisited7-17
Using Logging7-19
Logging Basics7-20
Logging Configuration7-21
Big Picture7-23
Contract Programming7-26
Optimized mode7-27
__debug__ variable7-28
Error Handling7-29
The Python Debugger7-30
Python Debugger7-32
Debugging Example7-33
Python Debugger7-35
Profile Sample Output7-37

8. Generators

Generators 8-1
Iteration Everywhere8-3
Iteration: Protocol8-4
Customizing Iteration8-7
Generator Functions8-9
Producers & Consumers8-13
Generator Pipelines8-14
Generator Expressions8-20
Why Use Generators?8-25
The itertools Module8-28
More Information8-29

9. Working with Text

Working With Text9-1
Text Parsing9-3
Text Splitting9-4
Text Stripping9-5
Text Searching9-6
Text Replacement9-7
re Module9-10
re Usage9-13
re: Matching9-14
re: Searching9-15
re: Match Objects9-16
re: Groups9-17
re: Search Example9-19
re: Pattern Replacement9-20
re: Comments9-21
Generating Text9-23
String Concatenation9-24
String Joining9-25
String Joining Example9-26
Printing to a String9-27
String Interpolation9-28
Dictionary Formatting9-29
Template Strings9-30
Advanced Formatting9-31
Text Input/Output9-33
Line Handling9-34
Universal Newline9-36
Text Encoding9-38
International Characters9-39
Unicode Characters9-41
Unicode Charts9-42
Using Unicode Charts9-43
Unicode Representation9-45
Unicode I/O9-46
Unicode File I/O9-47
Unicode Encoding9-48
Encoding Errors9-49
Finding the Encoding9-52
Unicode Everywhere9-53
A Caution9-54

10. Binary Data Handling

Binary Data Handling and File I/O10-1
Binary Data10-4
Common Scenarios10-5
Binary Data Representation10-6
Binary File I/O10-8
Binary Data Packing10-9
struct module10-10
struct Example10-13
Binary Type Objects10-15
ctypes library10-16
ctypes types10-17
ctypes structures10-19
Direct I/O10-20

11. Python Integration Primer

Python Integration Primer11-1
Python Integration11-2
Simple Subprocesses11-5
subprocess Module11-6
Executing Commands11-7
Specifying the Command11-8
Capturing Output11-9
Sending/Receiving Data11-10
I/O Redirection11-12
Collecting Status Codes11-13
Polling a Subprocess11-15
Killing a Subprocess11-16
Data Interchange11-18
XML Overview11-19
XML Example11-20
XML Parsing11-21
etree Parsing11-22
Obtaining Elements11-23
Iterating over Elements11-24
Element Attributes11-25
Network Programming11-27
Low-level Sockets11-28
A Simple Web Server11-29
Simple XML-RPC11-31
ctypes Module11-34
ctypes Example11-35
ctypes Caution11-37
ctypes Types11-38
ctypes Cautions11-40
ctypes and C++11-41
Extension Commentary11-42
COM Extensions11-44
Pythonwin and COM11-45
Python COM Client11-47
Python as a client11-48
Using a COM object11-49
Sample Output11-50
Jython Example11-53
IronPython Example11-57

12. A Few Advanced Topics

A Few Advanced Topics12-1
Variable Arguments12-3
Variable Keyword Use12-6
Variable Arguments12-7
Passing Tuples and Dicts12-8
List Sorting Revisited12-10
List Sorting12-11
Callback Functions12-13
Anonymous Functions12-14
Using lambda12-15
lambda and map()12-16
Advice on Lambda12-17
Delayed Evaluation12-19
Using Closures12-23
Function Decorators12-25
An Example12-26
A Variation12-28
Why? Why?! WHY!?!12-30
Using Decorators12-31
Scenario: Error Handling12-32
A Decorator Solution12-35
Decorated Methods12-40
Static Methods12-41
Using Static Methods12-42
Class Methods12-43
Using Class Methods12-44
Advanced Properties12-47
Creating a Package12-50
Using a Package12-52
__init__.py files12-53
Package Issues12-54
That's All Folks!12-56
Advanced Topics12-57
Shameless Plug12-58
Copyright (C) 2009-2010, Dabeaz LLC. All Rights Reserved.