#!/usr/bin/env python from cPickle import dump from thing import Thing, ThingCollection from animal import Animal, Mammal toothbrush = Thing("my toothbrush") cat = Mammal("my cat") cat.set_num_legs(4) giant_lizard = Animal("Tyrannosaurus rex") giant_lizard.set_furry(0) giant_lizard.set_num_legs("2 big, 2 small") # type error! collection = ThingCollection() collection.add_thing(toothbrush) collection.add_thing(cat) collection.add_thing(giant_lizard) f = open("things.pkl", "w") dump(collection, f) f.close()