tailot's picture
Upload folder using huggingface_hub
1600cd6 verified
Raw History Blame Contribute Delete
484 Bytes
"""Reading and writing plain text notes on disk.
One function opens a file and closes it by hand, which is the shape the context manager
pattern rewrites. The other already scopes its handle, and the pattern says so.
"""
def read_note(path):
handle = open(path, "r", encoding="utf-8")
body = handle.read()
handle.close()
return body
def write_note(path, body):
with open(path, "w", encoding="utf-8") as handle:
handle.write(body)
return len(body)