# Import(s) #
import json
from chat import message_handler as me
import random
#############
mind = {"message": "null","mID": 0,"reply": "null"}
def learn(m):
getMessage = m
getReply = me.reply
strReply = getReply.__str__
mind["mID"] = random.randint(0,10000000)
mind["message"] = getMessage
mind["message"] = strReply
with open("../data/TEMP.json", "w") as t:
json.dump(mind, t)
saveLearned()
def saveLearned():
temp = open("../data/TEMP.json")
brain = open("../data/conv.json")
with open("../data/conv.json", "w") as f:
json.dump(temp, brain)
I have this code, it is a module to "learn" new answers to x commands. First save the new "fragment" to write in a temporary file, then pass it to the final file (so I have a small record and I keep a little more informed of small errors that may occur without having to search the final file). The problem is that when I compile it, it returns the error "TypeError: Object of type method-wrapper is not serializable JSON". I have been looking for a solution for a while after having tried many things ... but I can not solve it correctly. Could someone help me a little? At least guide me a little, I'm pretty lost with this error and I can not find a convenient solution.