Announcements | Summary | Readings | Software | Schedule

Programming in Python

Autumn Term, 2011
(10 Sessions) Tuesdays 6 - 9 pm, October 11 through December 13, downtown Seattle.

UW Certificate Program in Python Programming, also includes Internet Programmming in Python (Winter 2012) and System Development with Python (Spring 2012).

This course will be similar to last year: Autumn 2010, Winter 2011, Spring 2011.


Announcements and updates:

The schedule is updated every week, consult frequently (refresh your browser).

Dec 12: Winter quarter begins Tuesday night, January 3
Dec 11: Winter quarter course page posted with week 1 reading assignment.
Dec 6: Seattle Python Interest Group (SeaPIG) meeting next Thurs Dec 15: lightning talks
Dec 4: Fix typos in assignment for Dec 6: def not define
Dec 1: Add recommended readings on Python ecosystem to Week 9 in schedule.
Nov 16: I forgot to link set.py to Nov 8 in schedule last week. Now fixed.
Nov 9: Seattle Python Interest Group (SeaPIG) meets Thursday, Nov 10
Oct 31: Some comments on our textbook
Oct 28: And, please read my comments on the homework assignment for week 3.
Oct 26: Please read my comments on the homework assignment for week 2.
Oct 19: Summaries of lightning talks
Oct 14: Results of the entry questionnaire
Oct 12: Add schedule for lightning talks (also below)
Oct 10: Revise schedule, assign more reading for week 2, add exercise
Aug 9: First class Oct 11 6:00 pm, downtown Seattle


Course objectives: Introduce the Python language, its most important libraries, and its recommended programming styles and idioms. Teach how to solve typical programming problems in Pythonic style. Survey some exemplary Python applications and systems. Teach career skills and work habits including testing and version control. Students will begin accumulating a portfolio of completed assignments, working toward a substantial original project in the Spring.

Prerequisites: No previous Python experience is required. This course is not intended for absolute beginners in programming, but does include a self-contained review of elementary features. Students must be able to use a command line, edit a text file, and download and install software. Students should have some prior exposure to programming in any language, sufficient to write very simple programs or scripts that use variables, conditionals (if ...), and iteration (loops).

Textbooks: The textbook comes in two versions: a printed book named Python for Software Design, and a free online version named Think Python. Despite the different titles, the two versions have the same contents.

Instructor: Jonathan Jacky is a research scientist at the University of Washington. He has experience as a software developer for research laboratories, hospitals, and systems software companies. He has taught at universities and in industry, and is the author of two textbooks on software development and testing. His Python experience includes the GNU Radio signal processing system, the FLiP proof checker, and the PyModel testing framework.

Technology Requirements: Students must have access to a computer for their assignments and projects, where they can install software (the course does not provide a computer laboratory). Older computers and computers with modest resources (including netbooks) will work. Any popular operating system will work, including Windows, Mac OS X, and Linux. It is recommended that students have a portable computer to bring to class. Internet access will be provided at classes.

Assessment criteria: The course is graded Pass/Fail, based on satisfactory completion of required programming assignments and classroom presentations. Attendance is required; more than two unexcused absences will result in a Fail.

Disability accommodation: The University of Washington is committed to providing access and reasonable accommodation in its services, programs, activities, education and employment for individuals with disabilities. For information or to request disability accommodation contact: Disability Services Office: 206.543.6450/V, 206.543.6452/TTY, 206.685.7264 (FAX), or e-mail at dso@u.washington.edu.


Textbook

The textbook comes in two versions, a printed book:

Python for Software Design: How to Think Like a Computer Scientist by Allen B. Downey. Cambridge University Press, 2009.

and a free online version:

Think Python: How to Think Like a Computer Scientist

Despite the different titles, the two versions have the same contents, including the same chapter, section, and exercise numbers. You may use the version you prefer.

This text is an excellent introduction to Python language fundamentals and semantics. There are many features and topics it does not discuss. We will discuss them in class and assign supplementary readings. Here are some comments on the book.

Summaries

Quick Python Script Explanation for Programmers (one page)
Learn Python in 10 minutes
NanoPy

Reference

Python 2.6 Quick Reference (awesomely dense and complete)
Python 2.x documentation (official documentation from python.org)

Supplementary texts

The Python Tutorial (from python.org)

IDLE Interactive Development Environment

Reference from python.org
Quick tour with screenshots

Other resources

Examples and Resources (other courses and books, sample code, notable Python libraries and scriptable applications)


Software

Students will need Python installed on their computers. Python comes already installed on Macs and most Linux distributions.

There are two different "current" versions of Python, 2.x and 3.x. We will be using 2.x, where x means any sufficiently recent version. 2.7 is most recent, but 2.6 will also work.

The current Python 2.x version is available here. I use this source for Windows. For the Mac, I use macports, which manages multiple Python versions nicely. For Linux, I use the distro's package manager (Synaptic on Ubuntu, for example).


Schedule and Assignments

Tuesdays 6 - 9 pm, October 11 through December 13 (10 sessions).

Additional topics and readings will be added, consult frequently (refresh your browser).

Read the assignment and do the assigned exercises in the week before class. Turn in the exercises (hardcopy) in class. Here PySD/TPy refers to the textbook, either Python for Software Design (printed) or Think Python (online). Both versions use the same chapter numbers (but in the TPy web pages, Chapter 2 is in file book003.html etc.)

WeekDateTopics Assignments due
(optional readings in parentheses)
1Oct 11 Introductions. Some Python applications and systems. Installing Python. Using the command interpreter and development environment. Finding and using the documentation. Getting help.

Lecture notes: intro.txt, python.txt, lightning.txt, values.txt
Code and data: schedule.py, students.txt, schedule.txt
Summaries (here), (here).
2Oct 18 Variables, values, expressions, and assignment. Functions. Definition and use. Arguments. Block structure. Scope. Modules and import.

Boolean expressions. Conditionals and control flow. Iteration and recursion.

Lecture notes: review_2.txt, assign.txt, boolean.txt, iteration.txt, functions.txt
Code: repetition.py, avg.py, scope.py

Exercise: my solution and comments

Lightning talks: Greg C, Deborah C, Shruti M, Ted S
PySD/TPy, Chs. (1), 2, 3, (4)

PySD/TPy 5, 6, 7

Exercise due Oct 18
3Oct 25 Data types. Sequences. Strings. Files. Exceptions. Text Processing. Regular expressions. Unicode.

Lecture notes: functions.txt again, strings.txt, files.txt, biopython.txt

Code and data: functions.py, parameters.py, strings_files.py, command_line.py, concordance.py, bio_demo.py, ceru_human.sp (same as ceru_human.txt)

Exercise: my solution and comments

Lightning talks: Noah G, Chris K, Mark P, Conor R
PySD/TPy, Chs. 8, 9, 14

( String methods)
(RegEx
How-To)
(Unicode How-To, more)

Exercise due Oct 25
4Nov 1 Data types. Sequences again. Tuples, Lists, Dictionaries. Mutability. Aliasing. Argument passing. List comprehensions.

Lecture notes: week_4.txt, sequence.txt
Code: traffic.py, phones.py

Exercise: my solution and comments

Lightning talks: Jenny L, Andy N, Shashi P, Kamal S
PySD/TPy, Chs. 10, 11, 12, 13

Exercise due Nov 1
5Nov 8 Data types, comprehensions again. Sets and Bags. Arrays. Functional programming and lambda. Data type case studies and review.

Lecture notes: week_5.txt, collections.txt, functional.txt
Code: phones.py, comprehensions.py, roman.py, corrector.py, set.py
Sample data: big.txt, words

Exercise: my solutions sorted_string.py and sorted_list.py, and comments

Lightning talks: Diana M, John M, Tony M, Michele W
Python Tutorial, sections 3.1.4, 5

Spelling corrector

Exercise due Nov 8
6Nov 15 Classes, instances, and methods. Object-oriented programming. Inheritance and duck typing.

Lecture notes: classes.txt
Code: patient.py, vehicle.py, simulator.py, pedestrian.py

Exercise: my solution unlisted_words.py

Lightning talks: Bob A, Scott B, Anton F, Daniel M
PySD/TPy, Chs. 15, 16, 17, 18

Exercise due Nov 15
7Nov 22 Extending Python. Special attributes and methods. Iterators and Generators. Protocols.

Lecture notes: week_7.txt, vector.txt, generator.txt, protocol.txt
Code: vector.py, generator.py
Lab Exercise: objects_lab.py

Exercise: my solution atom.py

Recommended readings (read as much as your time and interest allows):
Special Methods, learn about __str__, __add__ and their many many cousins.
Generator Tricks for Systems Programmers

Lightning talks: Stefan C, Martin C, Lotus L
Python Tutorial, Section 9 (except 9.9 - 9.11)

Recommended: See panel at left

Exercise due Nov 22
8Nov 29 Classes and inheritance again. Decorators. The debugger.

Lecture notes: week_8.txt, decorator.txt, debugger.txt
Code: decorator.py, repetition.py
Lab Exercise: inheritance_lab.py

Exercise: my solution bag.py

Recommended readings (read as much as your time and interest allows):
Decorators, gives some idea of what's possible
pdb - The Python Debugger
Python Types and Objects, Attributes and Methods, if you want to know what's really going on

Lightning talks: Gregg L, Alex W, Josh W
Python Tutorial, Sections 9.9 - 9.11

Recommended: See panel at left

Exercise due Nov 29
9Dec 6 Python ecosystem. Packages. PyPI. Installation. Python with other languages.

Lecture notes: week_9.txt, packages.txt, install.txt, other_languages.txt
Code: setup.py, integrate.py, integrate.pyx, setup_integrate.py, integrate.c

Lab Exercise: isa_hasa_lab.py

Exercise: my solution decorator_generator.py

Recommended readings (read as much as your time and interest allows):
Modules and Packages
CheeseShop Tutorial (PyPI)
Installation and distutils
C-API, SWIG, Cython

Lightning talks: Dimitry V
See panel at left

Exercise due Dec 6
10Dec 13 Databases and Python

Recommended readings (read as much as your time and interest allows):
Introduction to relational databases and SQL (source of the mailing list example), more here, here, and here.
SQLite: quick start, shell commands, language reference
Python's built-in sqlite3 library

Lecture notes: week_10.txt, databases.txt
Code: mailing_list, mailing_list_data, mailing_list_queries, mailing_list_queries.py

Lab Exercise: database_lab.txt, solution: database_lab.py

Python Glossary, a summary of where we've been, with hints about topics we didn't cover.

Lightning talks: Ben B, Maryam A, Brittany N
See panel at left

Exercise due Dec 13

Announcements | Summary | Readings | Software | Schedule


Jonathan Jacky, jon at u dot washington dot edu