import pickle
class dotdict(dict):
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
file = open("file.plk", "wb")
pickle.dump(dotdict({"a": 12}), file, protocol=pickle.HIGHEST_PROTOCOL)
file.close()
dotdict
is from this answer
What I don't understand is why this error is thrown
Traceback (most recent call last):
File "/home/ec2-user/environment/test.py", line 12, in <module>
pickle.dump(dotdict({"a": 12}), file, protocol=pickle.HIGHEST_PROTOCOL)
TypeError: 'NoneType' object is not callable
Is there any workaround, I would be grateful!