I like to say the class is a "mother ship" and serves as a kind of "home base" or "platform". How about an "amusement park"?
Another one to limber up on:
# -*- coding: utf-8 -*- """ Created on Wed Apr 20 15:27:35 2016
@author: Kirby Urner Carnival Guy (aka "geek", luvs chicken)
"""
class Blech(Exception): pass
class AmusementPark: # euphemism for carnival
@classmethod def ferris_wheel(A, me): me.sick = False return me
@classmethod def roller_coaster(A, me): # 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): 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
A1.ferris_wheel(alice) print("Sick after ferris wheel:", alice)
# time to eat! try: alice("cotton candy") alice("diet doctor pepper") alice("hot dog with onions") except: print("I'll eat later...")
A1.roller_coaster(alice) print("Sick after roller coaster?", alice) # it always happens
# time to eat! try: alice("popcorn") alice("gum drops") alice("another diet doctor pepper") except: print("I'll eat later...")