Last active
April 13, 2021 16:56
-
-
Save gar1t/502b767ff3fa3ed187e1f63eaeb5029e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
train: | |
flags-dest: global:config | |
flags-import: all | |
train2: | |
flags-dest: namespace:config | |
flags-import: all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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