Once students have mastered the basics of Python via our introductory Python course or their own work, it’s time to move on to applying Python to daily programming needs. This course picks up where Python I leaves off, covering some topics in more detail, and adding many new ones, with a focus on enterprise development.

This is a hands-on programming class. All concepts are reinforced by informal practice during the lecture followed by lab exercises. Many labs build on earlier labs, which helps students retain the earlier material.

Python II is 40percent hands-on, 60 percent lecture, with the longest lecture segments lasting for around 45 minutes. Students “learn by doing,” with immediate opportunities to apply the material they learn to real-world problems.

Course Duration: 4 days
Prerequisites:

All students should be able to write simple Python scripts, using basic data types, program structures, and the standard Python library.

Hardware and Software Requirements:

The following should be installed on each student PC:

  • Python 2.6 or later (available from http://www.python.org)
  • Any common database manager (MySQL, SQLlite, etc.)
  • Python packages setuptools, pylint, MySQLdb, sh
  • An IDE or programmer’s editor (Komodo Edit, Spyder, sublime, Eclipse, gVim, Notepad++, Emacs, etc.)
  • Any operating system (Windows, OS X, Unix/Linux)
Course Objectives:

All students will learn to use Python to:

  • Leverage OS services
  • Code graphical interfaces for applications
  • Create modules
  • Create and run unit tests
  • Define classes
  • Interact with network services
  • Query databases
  • Process XML data
Course Outline:
  • Python Refresher
    • Data types
    • Sequences
    • Mapping types
    • Program structure
    • Files and console I/O
    • Conditionals
    • Loops
    • Built-ins

 

  • 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

 

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

 

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

 

  • Metaprogramming
    • Implicit properties
    • globals() and locals()
    • Attributes
    • The inspect module
    • Decorators
    • Monkey patching

 

  • Programmer Tools
    • Analyzing programs
    • Using pylint
    • Testing code
    • Using unittest
    • Debugging
    • Profiling

 

  • Distributing Modules
    • Distribution concepts
    • setuptools
    • Creating setup.py
    • Building installers
    • Running installers

 

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

 

  • GUI Programming with Tkinter
    • Overview
    • The main window object
    • Widgets
    • Colors and fonts
    • GUI layout
    • Event handling

 

  • GUI Programming with PyQt4
    • Overview
    • A minimal QT application
    • Objected-oriented PyQt4
    • Using the designer
    • Wiring up events
    • Using predefined dialogs
  • Network Programming
    • Sockets
    • Clients
    • Servers
    • Application protocols
    • Forking servers
    • Threaded servers
    • Binary data
    • The struct module
  • 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
    • Alternatives to threading

 

  • System Administration
    • Launching programs with subprocess
    • Remote access
    • Permissions
    • Data persistence
    • Command line options
    • Writing filters
    • Logging
  • XML and JSON
    • Working with XML
    • DOM and Sax
    • Introducing ElementTree
    • Parsing XML
    • Navigating the document
    • Creating a new XML document
    • JSON
    • Parsing JSON into Python
    • Converting Python into JSON
  • Extending Python
    • About non-Python modules
    • Overview of a C extension
    • Creating functions
    • Registering functions
    • Initialization code
    • Loading the module