Skip to content

Instantly share code, notes, and snippets.

@gar1t
Last active April 13, 2021 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gar1t/502b767ff3fa3ed187e1f63eaeb5029e to your computer and use it in GitHub Desktop.
Save gar1t/502b767ff3fa3ed187e1f63eaeb5029e to your computer and use it in GitHub Desktop.
train:
flags-dest: global:config
flags-import: all
train2:
flags-dest: namespace:config
flags-import: all
config = {"x": 2, "y": 3}
class Trainer:
def __init__(self, **config):
self.__dict__.update(config)
def train(self):
print("x=%s" % self.x)
print("y=%s" % self.y)
if __name__ == "__main__":
trainer = Trainer(**config)
trainer.train()
from types import SimpleNamespace
config = SimpleNamespace(x=2, y=3)
class Trainer:
def __init__(self, config):
self.config = config
def train(self):
print("x=%s" % self.config.x)
print("y=%s" % self.config.y)
if __name__ == "__main__":
trainer = Trainer(config)
trainer.train()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment