def exit(self, miner): print( "\n{0}: Thankya lille lady. Ah better get back to whatever ah wuz doin'" .format(miner)) def on_message(self, miner, msg): """ The GlobalState for the miner will handle messages """ return False if __name__ == '__main__': from miner import Miner bob = Miner() ## state = GoHomeAndSleepTilRested.instance() ## state.enter(bob) ## state.execute(bob) ## state.exit(bob) state = EnterMineAndDigForNugget.instance() state = VisitBankAndDepositGold.instance() state = QuenchThirst.instance() print(state) bob.change_state(state) bob.current_state.execute(bob) bob.current_state.exit(bob)