Skip to content Skip to sidebar Skip to footer

Compare Lists In Python While Looping

I have a script which I'm using to read an excel file and update an SQL database. I'm reading the excel file every 30 seconds using a loop. However I only want to update the databa

Solution 1:

Yes, Python built-in containers are compared by value (both tuples, lists and dicts).

Something like this (I used a list comprehension to add fanciness):

//init
pvv=None

<...>

//iteration
vv= [data.cell(i,j).valuefor (i,j) in ((2,26),(3,26),(4,26))]
if vv!=pvv: 
    //do something
    pvv=vv

Post a Comment for "Compare Lists In Python While Looping"