forjinrange(len(history)):if(message["email"]inhistory[j]):ifhistory[j][2]=="no":# Question and then customer_idquestions_2=eval(history[j][3].replace("$",","))iforder_info!={}:response,answer_id=detect_response(shop,questions_2,order_info,message,history)history[j][2]=order_info["customer_id"]elif"not_customer"inquestionsand"status"inquestions_2:question_2=["status","not_customer"]order_info_2={"status":"none","time":400,"order_time":400}response,answer_id=detect_response(shop,questions_2,order_info_2,message,history)else:response="/ALERT I could not find info on this customer"answer_id="s9"eliforder_info!={}:response,answer_id=detect_response(shop,questions,order_info,message,history)else:response="/ALERT I could not find info on this customer"answer_id="s9"answer_ids=list(eval(history[j][4].replace("$",",")))ifanswer_idnotinanswer_ids:answer_ids.append(answer_id)else:return"/ALERT This customer often asks me the same question","/ALERT"history[j][4]=str(answer_ids)lst=[]#rebuild the file contentforlst3inhistory:lst.append(",".join(lst3))cont="\n".join(lst)file=open("shops/{}/history.csv".format(shop),"w")file.write(cont)file.close()returnresponse,answer_id
peut devenir :
forjinrange(len(history)):if(message["email"]inhistory[j]):returnhandle_email(X,Y,Z)# toujours pareil...
Ce qui donne la fonction :
defbuild_answer(shop,order_info,message,questions,history,is_buffalo):questions_2=["info_not_found","none"]history_line=Noneforjinrange(len(history)):if(message["email"]inhistory[j]):returnhandle_email(X,Y,Z)# toujours pareil...response,answer_id,info=prepare_response(paramA,paramB)# ajuster les params# Build the file contentlog_response(param1,param2)# mettre les paramètres nécessairesreturnresponse,answer_id
Un peu plus clair, non ?
Note : prendre aussi en compte les remarques précédentes
Note 2 : les opérations de log peuvent être factorisées également... toujours même raison.
[^] # Re: Moult remarques
Posté par _kaos_ . En réponse au message Python: Return value not found in function. Évalué à 3. Dernière modification le 31 mars 2021 à 07:53.
Et encore même chose pour plus haut, je pense :
peut devenir :
Ce qui donne la fonction :
Un peu plus clair, non ?
Note : prendre aussi en compte les remarques précédentes
Note 2 : les opérations de log peuvent être factorisées également... toujours même raison.
Matricule 23415