On Wed, Apr 20, 2016 at 3:58 PM, Carl Karsten <c...@nextdayvideo.com> wrote:
> I also don't show real code right away. I scribble on the white board. > > Yeah, I think we're just talking about different points along the journey. I'm fine with Blueprint and/or Cookie Cutter at first, as the predominant metaphor, and not too much code. But then in my code school boot camp model they might have 12 weeks x 40 hours to learn all this JavaScript -> Other Language -> Python -> JavaScript (they go round and round in a spiral in this curriculum). So down the road a ways, when it's important to understand more of the Python grammar, I might move away from Blueprint and Cookie Cutter to MotherShip and AmusementPark. [ The version below keeps statistics at the class level (turnstyles...). ] I like your relating programming to processing video. I'm working to forge that connection more explicitly myself. The idea of "frames" (as in time frames, frames of file, intervals of action) figures in. Kirby # -*- coding: utf-8 -*- """ Created on Wed Apr 20 16:44:44 2016 @author: Kirby Urner Carnival Guy (aka "geek", luvs chicken) version 0.2 (copyleft) MIT License """ import random class Blech(Exception): pass class AmusementPark: # euphemism for carnival ferris_riders = 0 coaster_riders = 0 riders_born = 0 @classmethod def report(A): return "Ferris rides: {}\nCoaster rides: {}\nRiders: {}".\ format(A.ferris_riders, A.coaster_riders, A.riders_born) @classmethod def ferris_wheel(A, me): A.ferris_riders += 1 me.sick = False return me @classmethod def roller_coaster(A, me): A.coaster_riders += 1 # moral: don't eat before riding the roller coaster if len(me.stomach) > 0: me.sick = True # sick state persists me.stomach = [] # ... this should help though return me @classmethod def make_rider(A): A.riders_born += 1 return A() def __init__(self): # born to ride self.stomach = [] self.sick = False def __call__(self, food): # born to eat if self.sick: raise Blech("too sick to eat") self.stomach.append(food) def __repr__(self): if self.sick: return "I don't feel so good" else: return "I feel fine" A1 = AmusementPark alice = A1.make_rider() # a child of her profession bob = A1.make_rider() carl = A1.make_rider() def time_frame(): while True: rider = random.choice([alice, bob, carl]) ride = random.choice([A1.ferris_wheel, A1.roller_coaster]) ride(rider) yield A1 frame = time_frame() for time_tick in range(10): next(frame) print(A1.report())
_______________________________________________ Edu-sig mailing list Edu-sig@python.org https://mail.python.org/mailman/listinfo/edu-sig