AttributeError: Can't pickle local object '<locals>.<lambda>'
AttributeError: Can't pickle local object '<locals>.<lambda>' Question: I am trying to pickle a nested dictionary which is created using: collections.defaultdict(lambda: collections.defaultdict(int)) My simplified code goes like this: class A: def funA(self): #create a dictionary and fill with values dictionary = collections.defaultdict(lambda: collections.defaultdict(int)) … #then pickle to save it pickle.dump(dictionary, f) However it gives error: AttributeError: …