forked from M-Labs/artiq
pyon: add file I/O functions
This commit is contained in:
parent
6de650a701
commit
85b4d70ced
|
@ -119,3 +119,19 @@ def decode(s):
|
|||
|
||||
"""
|
||||
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())
|
||||
|
|
Loading…
Reference in New Issue