Python - process only new element of dictionnary -


i have unique (unique keys) dictionnary update adding new keys depending data on webpage. , want process new keys may appear after long time. here piece of code understand :

a = uniquedict()  while 1:      webpage = update() # return list      in webpage:         title = gettitle(i)         a[title] = new_value # populate new title obtained because it's unique dictionnary          if len(a) > 50:             a.clear() # clear dictionnary if big      # condition before entering loop process new title entered     element in a.keys():         process(element) 

is there way know new keys added in dictionnary (because of time, same keys , values don't want them processed) ? thank you.

what might do, keep processed keys in set. can check new keys using set(d.keys()) - set_already_processed. , add processed keys using set_already_processed.add(key)


Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -