forked from M-Labs/artiq
1
0
Fork 0

pyon: add file I/O functions

This commit is contained in:
Sebastien Bourdeauducq 2014-12-03 17:18:43 +08:00
parent 6de650a701
commit 85b4d70ced
1 changed files with 16 additions and 0 deletions

View File

@ -119,3 +119,19 @@ def decode(s):
""" """
return eval(s, _eval_dict, {}) return eval(s, _eval_dict, {})
def store_file(filename, x):
"""Encodes a Python object and writes it to the specified file.
"""
with open(filename, "w") as f:
f.write(encode(x))
def load_file(filename):
"""Parses the specified file and returns the decoded Python object.
"""
with open(filename, "r") as f:
return decode(f.read())