Last active
February 19, 2022 17:48
-
-
Save tkutcher/f611e5ef61b2cc324076b54a6aeb6f07 to your computer and use it in GitHub Desktop.
Testing File IO demo 2
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
def read_from_file(src_path="my-config.json") -> MyConfig: | |
with open(src_path, "r") as f: | |
d = json.load(f) | |
return MyConfig(d["x"], d["y"]) | |
def write_to_file(c: MyConfig, dest_path="my-config.json") -> None: | |
with open(dest_path, "w") as f: | |
f.write({"x": c.x, "y": c.y}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment