Python II: Applied Python (4 days)

Synopsis

Once students have mastered the basics of Python, it's time to move on to applying Python to daily programming needs. This course picks up where Python I left off, covering some topics in more detail, and adding new ones. For instance, regular expressions and classes are covered extensively, with network programming (e.g. FTP, Web client and server), graphical programming, database access, and other areas of general need.

This course may be taught in either 4 or 5 days. In the 5 day version, the 5th day is devoted to more advanced work. The entire day is spent on the last chapter, "Putting Python to Work", which contains more in-depth exercises than the end-of-chapter labs. We also encourage students to bring in their own, real-life tasks for this portion of the course, so they can work on them in with the instructor as coach, mentor, and "second pair of eyes".

Target audience This course is appropriate for Python programmers who are ready to ramp their skill up to the next level.
Prerequisites

Students should be able to write simple Python scripts, using basic data types, program structures, and the standard Python library. Our Python I class provides this necessary background.

Lab exercises

As with all our programming classes, Python II has a generous complement of exercises that allow the student to immediately practice new concepts.

Students will write numerous real-world Python scripts which manipulate real-world data. exercises will increase in complexity as more sophisticated techniques are introduced.

Links Some links to sites a Python programmer may find useful

Course Outline

Python refresher

  • Data types
  • Sequences
  • Mapping types
  • Program structure
  • Files and console I/O
  • Conditionals
  • Loops
  • Builtins

OS Services

  • The os module
  • Environment variables
  • Launching external commands
  • Walking directory trees
  • Paths, directories, and filenames
  • Working with file systems
  • Dates and times

Pythonic Programming

  • The Zen of Python
  • Common idioms
  • Lambda functions
  • List comprehensions
  • Generator expressions
  • String formatting

Program development

  • Analyzing programs
  • Using pylint
  • Testing code
  • Using unittest
  • Debugging

Creating modules

  • Initialization code
  • Namespaces
  • Executing modules as scripts
  • Documentation
  • Packages and name resolution
  • Naming conventions
  • Using import

Classes

  • Defining classes
  • Instance methods and data
  • Initializers
  • Class methods
  • Static methods
  • Inheritance
  • Multiple inheritance
  • Pseudo-private variables

GUI programming

  • Graphical programming overview
  • About Tk
  • The TkInter module
  • Creating widgets
  • Packing widgets
  • Fonts, colors, and other widget attributes
  • Starting the application
  • Bindings and events

Database access

  • The DB API
  • Available Interfaces
  • Connecting to a server
  • Creating and executing a cursor
  • Fetching data
  • Parameterized statements
  • Metadata
  • Transaction control

Threads

  • Why use threads?
  • Threads are different
  • Variables are shared
  • Python threads modules
  • The threading module
  • The queue module
  • The python thread manager
  • Debugging threaded programs

CGI

  • The cgi module
  • URL encoding
  • Calling CGI scripts
  • CGI Environment variables
  • The FieldStorage object
  • Sending the HTTP header
  • Outputting HTML
  • HTML from templates

Network Programming

  • Sockets
  • Clients
  • Servers
  • Application protocols
  • Forking servers
  • Threaded servers
  • Binary data
  • The struct module

XML

  • Working with XML
  • DOM: The Document Object Model
  • Getting a DOM tree
  • Document nodes
  • Walking the tree
  • SAX: The simple API for XML
  • Creating a SAX reader
Return to course list