-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils.py
More file actions
33 lines (27 loc) · 776 Bytes
/
utils.py
File metadata and controls
33 lines (27 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import pickle
class Serialization:
@staticmethod
def save_obj(obj, name):
"""
serialization of an object
:param obj: object to serialize
:param name: file name to store the object
"""
with open('../pickle/' + name + '.pkl', 'wb') as fout:
pickle.dump(obj, fout, pickle.HIGHEST_PROTOCOL)
# end with
# end def
@staticmethod
def load_obj(name):
"""
de-serialization of an object
:param name: file name to load the object from
"""
with open('../pickle/' + name + '.pkl', 'rb') as fout:
return pickle.load(fout)
# end with
# end def
# end class
if __name__ == '__main__':
pass
# end if