Skip to content

Instantly share code, notes, and snippets.

@JohnDowson
Created December 12, 2019 10:36
Show Gist options
  • Save JohnDowson/cee03864642f4b151b6caddea698bd7c to your computer and use it in GitHub Desktop.
Save JohnDowson/cee03864642f4b151b6caddea698bd7c to your computer and use it in GitHub Desktop.
class ConfigParam():
def __init__(self, param_name, param_type, default):
self.param_name = param_name
# get parameter from config
_param = param_from_config()
if param_type:
# cast it to required type
self.value = asWhateverType(_param)
def __hash__(self):
self.param_name.__hash__
class ModuleParams():
def add(self, config_param):
self.__setattr__(config_param.param_name, config_param.value)
class Module():
def __init__(self):
super()
self.params.add(ConfigParam('show_stuff', bool, True))
def update(self):
if self.params.show_stuff:
showStuff()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment