« first day (749 days earlier)      last day (2592 days later) » 

11:22 PM
guys, i need help with some python debugging
    reader = csv.reader(open("Chat_Log.csv"))
    reader = list(reader)
    for data in reversed(reader):
        if int(data[0]) > self.temp:
            print(int(data[0]) > self.temp)
            #print("IN")
            if self.name != data[1]:
                print("PRINTING 1")
                self.label = Label(master=self.Label_Frame, text=data[3], wraplength=400, bg="blue")
            else:
                print("PRINTING 2")
                self.label = Label(master=self.Label_Frame, text=data[3], wraplength=400, bg="green")
its a tkinter application
the problem is that it keeps creating a label (doesnt matter what label, the problem is that it is creating a label when it shouldnt)
i have it so that it should only create a label when int(data[0]) is bigger than self.temp
im tryna debug it, here is my output from the prints
True
PRINTING 2
19
OUT
20
True
PRINTING 2
19
OUT
20
this carries infinitely
i dont understand why, nor how to fix it
any help at all will be useful and any information needed will be provided
in the tkinter app i have an entry box which when pressed enter adds more text to the "chat_log" file
def send_message(self, event=None):
    now = datetime.datetime.now()
    time = str(now.hour) + str(now.minute)
    message = self.user_message.get()
    to_be_sent = [self.temp+1,self.name,time,message]
    if len(message) > 0:
        with open("Chat_Log.csv", "a") as f:
            writer = csv.writer(f, delimiter=",", lineterminator="\n")
            writer.writerow([self.temp+1,self.name,time,message])
        self.user_message.delete(0, "end")
i fixed the problem
the problem was when assigning self.temp to be equal to data[0], it would pick the second message, not the first
if self.new_temp < int(data[0]):
self.new_temp = int(data[0])
...
self.temp = self.new_temp + 1
adding this fixed my problem
 

« first day (749 days earlier)      last day (2592 days later) »