Skip to content

Instantly share code, notes, and snippets.

@maxp
Created March 20, 2010 12:01
Show Gist options
  • Select an option

  • Save maxp/338632 to your computer and use it in GitHub Desktop.

Select an option

Save maxp/338632 to your computer and use it in GitHub Desktop.
# Use a flag to indicate the state of the bus.
class _StateEnum(object):
class State(object):
name = None
def __repr__(self):
return "states.%s" % self.name
def __setattr__(self, key, value):
if isinstance(value, self.State):
value.name = key
object.__setattr__(self, key, value)
states = _StateEnum()
states.STOPPED = states.State()
states.STARTING = states.State()
states.STARTED = states.State()
states.STOPPING = states.State()
states.EXITING = states.State()
# from cherrypy/process
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment