Generators, Python Objects, Classes, Exceptions




CS156

Chris Pollett

Sep 13, 2017

Outline

Introduction

Generators

Coroutines

Objects and Classes

Inheritance, static methods, abstract classes.

Tic-tac-toe Board Example

In-Class Exercise

Create a subclass of the Board class of the previous slide with a new method movePiece(self, x1, y1, x2, y2) which takes whatever the square is at location `(x1, y1)` and replaces the square at `(x2, y2)` with that value, then write a '.' at location `(x1, y1)` on the board. After your class definition, writes a few lines to test out your code.

Post your solutions to the Sep 13 In-Class Exercise Thread.

Exceptions

Modules

Documentation Strings and Help