I have a problem with loading .pickle files which contain objects of the class collections.defaultdict.
I'm aware, that there are many answers regarding this topic out there (e.g. here), however none of them worked out.
I want to read the files of someone I'm collaborating with and he has apparantely no issues in saving defaultdicts as .pickle files, as his codes looks like the following:
dict_ = defaultdict()
example_keys = ["a", "b", "c"]
for i, key_ in enumerate(example_keys):
dict_[key_] = 2 * i
pickle.dump(dict_, open("dict_.pickle", "wb"))
And he seems to have no issues, when loading this very file in his code lateron.
However, when I try to load the file using
from collections import defaultdict
with open("dict_.pickle", "rb") as handle:
dict_ = pickle.load(handle)
I get Unable to get repr for <class 'collections.defaultdict'>.
Is there a way to fix this for me? Or should I ask my collaborator to switch to "normal" python dicts?