I've been using this for a while - I can't recall where I found it:
#####
# An enumeration is handy for defining types of event
# (which otherwise would messily be just random strings)
def enum(**enums):
return type('Enum', (), enums)
#####
# The control events that the Controller can process
# Usually this would be in a module imported by each of M, V and C
# These are the possible values for the "event" parameter of an APP_EVENT message
AppEvents = enum(APP_EXIT = 0,
CUSTOMER_DEPOSIT = 1,
CUSTOMER_WITHDRAWAL = 2)
How does it work?