Skip to content

Instantly share code, notes, and snippets.

@zzzeek
Last active December 17, 2015 05:28
Show Gist options
  • Select an option

  • Save zzzeek/5557643 to your computer and use it in GitHub Desktop.

Select an option

Save zzzeek/5557643 to your computer and use it in GitHub Desktop.
attempting to come up with an example of subclassing enums
class CoinType(Enum):
"types of coins we keep track of."
penny = 1
nickel = 2
dime = 3
quarter = 4
dollar = 5
class DefaultCoinUsage(CoinType):
"""Represent what coin type the administration
interface should use on startup.
Is stored in prefs.default_coin_type
"""
ask_user = 6 # ask at startup and store per session
last_used = 7 # use the user's last selection from the previous session
class CoinQuery(CoinType):
"Represent criteria for searching among coin records."
all = 6 # query across all coins
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment