All pastes #175815 Raw Edit

Cody Brocious

public python v1 · immutable
·published 2006-09-19 04:27 UTC
rendered paste body
#!/usr/bin/env python# encoding: utf-8"""test.pyCreated by Cody Brocious on 2006-09-18.Copyright (c) 2006 Falling Leaf Systems, LLC. All rights reserved."""import sysfrom FSM import State, StateMachinedef endState(fsm):	print 'Finished'		return Noneclass Counter(StateMachine):	def __init__(self, min=0, max=100, print_increment=5):		StateMachine.__init__(self)				self.addState(self.mainState)		self.addState(self.printState)				# Example of adding a state outside the class		self.addState(endState)				self.current = min		self.max = max		self.print_increment = print_increment				self.run(self.mainState)		def mainState(self, fsm):		if self.last_state != self.printState and self.current % self.print_increment == 0:			return self.printState		self.current += 1				if self.current == self.max:			return endState		else:			return self.mainState		def printState(self, fsm):		print self.current				return self.mainState	if __name__ == '__main__':	Counter()	Counter(min=0, max=5000, print_increment=100)