Object-oriented Python, one subway system at a time.

A small, dependency-free codebase that models a city subway with classes. Read it to see how objects collaborate; run it to watch them; extend it to make the ideas yours.

Run it

Standard library only — nothing to install beyond Python 3.

git clone https://github.com/michael-borck/objectville.git
cd objectville
python Subway.py

The classes

Five small files, each with one job — the object-oriented idea in miniature:

The city map lives in ObjectvilleSubway.txt — edit it, add a line, and rerun. Objectville itself is a tip of the hat to the town where the Head First books taught a generation of programmers objects.

Try extending it

Good first exercises: add a get_directions that finds a route between two stations; add fares per connection and price a journey; write a second loader that reads JSON instead of text — and notice how little else has to change.