ICS 32 Spring 2015
Code Examples

Code examples, from lecture and otherwise

Over the course of the quarter, when I write substantial code examples in lecture — beyond just experimentation in the Python interpreter or short code fragments — I will be turning them into full-scale code examples and posting them here for you. Be aware that there is a process involved in fleshing out a lecture example — rather than just posting code exactly as we wrote it, I'd like to turn it into something more complete and instructive — and this process takes some time, so it's best, in general, not to expect these to be available right away, but I will generally try to have them available before the next lecture, at the latest.

Note that you are not permitted to simply copy and paste this code into your own projects, but, of course, the techniques employed may also be of general use to you in your work. These examples are intended to give you clean, well-documented examples of some of the things we cover in lecture (and possibly a few things that we don't, time permitting), so that you can be free in lecture to avoid trying to take detailed notes when we're writing code together, instead concentrating on understanding the process and the bigger-picture concepts at work.

Lecture Date(s) Description
Th 4/2 Exceptional control flow in Python, applied to opening and reading from text files
Tu 4/7 Writing a recursive function to process a recursive data structure
Th 4/9 Sockets, Part 1: An example socket client
Tu 4/14 Sockets, Part 2: Improving our socket client using "pseudo-file" objects and a more careful design
Th 4/16
Tu 4/21
Implementing a custom network protocol (Yackety), plus writing programs with multiple modules
Th 4/23 Writing classes in Python
Tu 4/28 URLs and downloading data from the web in Python
Th 4/30 Web APIs, URL encoding, and JSON
Th 5/7 Duck typing and interfaces in Python
Tu 5/12
Th 5/14
Two-dimensional list algorithms
Th 5/14
Tu 5/19
Basics of the tkinter library for implementing graphical user interfaces
Tu 5/19
Th 5/21
Canvases, custom drawing, and object-oriented programming using tkinter
Th 5/21
Tu 5/26
Alternative coordinate systems and resizing a custom-drawn picture when a tkinter Canvas is resized
Tu 5/26
Th 5/28
The Spots application in tkinter
BONUS The grid layout manager, in detail
Tu 6/2 Modal dialog boxes in tkinter, plus the use of control variables