jsonpickle

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: …

Total answers: 2

Avoid jsonpickle using py/id pointer to another object

Avoid jsonpickle using py/id pointer to another object Question: When an object is serialized to json using jsonpickle, I noticed objects such as datetime are stored once then future uses are stored as references value such as {“py/id”:1}. Is it possible store actual value instead of reference? This reference seems hidden and would be confusing …

Total answers: 4